//ÇйøÀ» ±âÁØÀ¸·Î ¼±ÅÃÁ¤·Ä
#include <stdio.h>
#include <string.h>
#define MAX_STUDENTS 10
typedef struct student_info {
char name[30];
int st_no;
char address[100];
int weight;
} student_info;
student_info hansung_univ[MAX_STUDENTS] = {
{"È«±æµ¿", 20110021, "¼¿ï½Ã ¼ººÏ±¸ »ï¼±µ¿"},
{"±èö¼ö", 20110011, "¼¿ï½Ã °³²±¸ ½Å»çµ¿"},
{"¾ç±Íºñ", 20110201, "°æ±âµµ °í¾ç½Ã Àϻ굿"},
};
void swap(student_info *a, student_info *b);
void sort(student_info a[3],int n);
int main(void)
{
for(int a=0;a<3;a++)
{
printf("%sÀÇ ¸ö¹«°Ô´Â[kg] : ",hansung_univ[a].name);
scanf("%d",&hansung_univ[a].weight);
}
sort(hansung_univ,3);
printf("\n============<¸ö¹«°Ô·Î ¼±ÅÃÁ¤·Ä>===========\n");
for(int k=0;k<3;k++)
{
printf("==========================================\n");
printf("%s %d %s %dkg\n",hansung_univ[k].name, hansung_univ[k].st_no, hansung_univ[k].address, hansung_univ[k].weight);
}
printf("==========================================\n");
return 0;
}
void swap(student_info *a, student_info *b)
{
student_info tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
void sort(student_info a[3],int n)
{
int i, j, index;
for (j = 0; j < n - 1; j++) {
index = j;
for (i = j + 1; i < n; i++) {
if (a[i].weight < a[index].weight) {
index = i;
}
}
swap(&a[j], &a[index]);
}
}