#include<stdio.h>
#include<string.h>
struct student
/*定义学生信息*/
{
char num;
char name[20];
char sex;
char major;
int chinese;
int math;
int english;
};
struct student str[30];
void com(struct student *score);
void main()
{
int i;
for(i=0;i<30;i++)
/*循环录入学生信息*/
{
printf("please input the num %d\n",i+1);
printf("please input the name \n");
printf("please input the sex\n");
printf("please input the major\n");
printf("please input the chinese score\n");
printf("please input the math score\n");
printf("please input the english score\n\n");
scanf("%d\n",&str[i].num);
scanf("%s\n",&str[i].name);
scanf("%c\n",&str[i].sex);
scanf("%s\n",&str[i].major);
scanf("%d\n",&str[i].chinese);
scanf("%d\n",&str[i].math);
scanf("%d\n",&str[i].english);
printf("\n");
}
com(str);
}
void com(struct student *score)
{
int a,b,c,d,e,j;
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;
for(j=0;j<30;j++)
{
switch(score[j].chinese / 10)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
e++;
break;
case 6:
d++;
break;
case 7:
c++;
break;
case 8:
b++;
break;
case 9:
case 10:
a++;
break;
default :
printf("error");
}
}
printf("不及格:%d\n,及格:%d\n,中:%d\n,良:%d\n,优:%d\n",e,d,c,b,a);
}
---------
现在好了
楼主试下