#include <stdio.h>
#include <string.h>
struct student{
char name[20];
int id;
char sex;
int kor, eng, math;
};
void main(){
struct student std[5];
int a, i;
int max1 = std[0].kor;
int max2 = std[0].eng;
int max3 = std[0].math;
int save1 = 0, save2 = 0, save3 = 0;
while (1){
printf("1.load 2.show 3.best score 4.male students 5.female students 6.change\nselect menu");
scanf("%d", &a);
switch (a){
case 1:
printf("enter name, id, sex, kor, eng, math for 5 students\n");
for (i = 0; i < 5; i++){
printf("student %d", i + 1);
scanf("%s %d %c %d %d %d", &std[i].name, &std[i].id, &std[i].sex, std[i].kor, &std[i].eng, &std[i].math);
}
break;
case 2:
printf("now displaying the students\n");
for (i = 0; i < 5; i++){
printf("student %d\n", i);
printf("name:%s student ID:%d sex:%c\n", std[i].name, std[i].id, std[i].sex);
printf("kor score:%d eng score:%d math score:%d\n", std[i].kor, std[i].eng, std[i].math);
}
break;
case 3:
for (i = 0; i < 5; i++){
if (max1 < std[i].kor){
max1 = std[i].kor;
i = save1;
}
}
for (i = 0; i < 5; i++){
if (max2 < std[i].eng){
max2 = std[i].eng;
i = save2;
}
for (i = 0; i < 5; i++){
if (max3 < std[i].math){
max3 = std[i].math;
i = save3;
}
}
printf("best score for korean : %s %d", std[save1].name, max1);
printf("best score for korean : %s %d", std[save2].name, max2);
printf("best score for korean : %s %d", std[save3].name, max3);
break;
case 4:
for (i = 0; i < 5; i++){
if (std[i].sex = 'M')
for (i = 0; i < 5; i++){
printf("student %d", i + 1);
scanf("%s %d %c %d %d %d", &std[i].name, &std[i].id, &std[i].sex, std[i].kor, &std[i].eng, &std[i].math);
}
}
case 5:
for (i = 0; i < 5; i++){
if (std[i].sex = 'F')
for (i = 0; i < 5; i++){
printf("student %d", i + 1);
scanf("%s %d %c %d %d %d", &std[i].name, &std[i].id, &std[i].sex, std[i].kor, &std[i].eng, &std[i].math);
}
}
case 6:
int j = 0;
printf("enter student ID");
scanf("%d", &j);
for (i = 0; i < 5; i++)
if (std[i].id = j){
printf("enter new data");
scanf("%s %d %c %d %d %d", &std[i].name, &std[i].id, &std[i].sex, std[i].kor, &std[i].eng, &std[i].math);
}
}
}
}
}
실행은 되는데 student1 입력하면 student2입력하도록 나와야 되는데 student1 입력하면 오류나요ㅠㅠㅠㅠㅠ