解题思路:
1)要一次输入多个值,利用结构体比较方便
2)对于奖学金的评定,有一些关于分数的要求,比较时可以自己为他们排一下序,比如如果不大于80,就不用可虑大于90了,所以把大于90的奖学金放在大于80的语句里面,可以减少一些不必要的资源浪费
注意事项:
1)利用数组,别忘了加[i]
参考代码:
#include<stdio.h>
#include<string.h>
struct Stu{ //定义结构体
char name[20];
int ave_grade;
int class_grade;
char ganbu;
char west;
int article;
int all;
};
int main(){
struct Stu student[100];
int N;
scanf("%d",&N);
int max=0,count=0; //最多奖学金得主,全部的奖学金总和
char maxname[20]; //最多奖学金得主名字
for(int i=0;i<N;i++){
//printf("name avegrade classgrade ganbu west article\n"); //输入提示
scanf("%s %d %d %c %c %d",&student[i].name,&student[i].ave_grade,&student[i].class_grade,&student[i].ganbu,&student[i].west,&student[i].article);
student[i].all=0; //赋初值
if(student[i].ave_grade>80){ //平均分>80
if(student[i].article>=1){ //院士奖学金发表文章>1
student[i].all+=8000;
}
if(student[i].ave_grade>85){ //平均分>85
if(student[i].class_grade>80){ //五四奖学金评议成绩>80
student[i].all+=4000;
}
if(student[i].west=='Y'){ //西部奖学金
student[i].all+=1000;
}
if(student[i].ave_grade>90){ //平均分>90
student[i].all+=2000; //成绩优秀奖
}
}
}
if(student[i].class_grade>80 && student[i].ganbu=='Y'){ //干部奖学金
student[i].all+=850;
}
if(i==0){
max=student[i].all;
}else{
if(student[i].all>max){
max=student[i].all;
strcpy(maxname,student[i].name);
}
}
count+=student[i].all;
}
printf("%s\n%d\n%d\n",maxname,max,count);
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:1514 |
C语言训练-计算1~N之间所有奇数之和 (C语言代码)浏览:646 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1816 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:552 |
C语言训练-大、小写问题 (C语言代码)浏览:724 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:526 |
关于float,double变量的几点说明浏览:1810 |
Hello, world! (C语言代码)浏览:824 |
字符串比较 (C语言代码)浏览:680 |
矩阵的对角线之和 (C语言代码)浏览:1345 |