【807】简单处理学生成绩
作者:互联网
#include<stdio.h>
#define N 10
struct student {
char stuNum[20];
int math;
int c;
};
void input(struct student *p,int n){
int i;
for(i=0;i<n;i++){
printf("plesae input the %d stuNun:",i+1);
scanf("%s",p[i].stuNum);
printf("Please input the %d math:",i+1);
scanf("%d",&p[i].math);
//注意此处对int输入要取地址&
printf("Please input the %d c:",i+1);
scanf("%d",&p[i].c);
getchar();//去除残留回车符
}
}
int main()
{
int m=0,i,maxScore=0;
struct student stu[N],max[N];
printf("please input student information:\n");
input(stu,N);
for(i=0;i<N;i++)
{
if(stu[i].c > maxScore)
{
maxScore=stu[i].c;
}
}
for(i=0;i<N;i++)
{
if(stu[i].c==maxScore){
max[m++]=stu[i];
}
}
printf("Last:\n");
printf("the best c has %d\n",m);
while(m-->0){
printf("%s,%d,%d\n",stu[m].stuNum,stu[m].math,stu[m].c);
}
return 0;
}
标签:int,学生,stu,student,printf,input,成绩,807,math 来源: https://blog.csdn.net/weixin_45253216/article/details/122006448