标签:style io ar color os sp for 文件 数据
1 4 YaoLin 87 82 Y N 0 ChenRuiyi 88 78 N Y 1 LiXin 92 88 N N 0 ZhangQin 83 87 Y N 1
ChenRuiyi 9000 28700
解题思路:
对于这种每个研究对象有多个数据的题目,用结构体无疑是最好的选择。对结构体的操作格式为是s[i].name,读取数据应该注意空格scanf("%s %d %d %c %c %d",s[i].name,......)
程序代码:
# include <stdio.h> struct StudentI{ char name[20]; int Qmpjcj; int Bjpycj; char Gb; char Xb; int Lw; int Jxj; }; int main() { StudentI s[100]; int N,X; scanf("%d",&N); while(N--){ int i,Max=0,Wz = 0,Sum = 0; scanf("%d",&X); for(i = 0; i < X; ++i){ scanf("%s %d %d %c %c %d",s[i].name,&s[i].Qmpjcj,&s[i].Bjpycj,&s[i].Gb,&s[i].Xb,&s[i].Lw); s[i].Jxj = 0; } for(i = 0; i < X; ++i){ if(s[i].Qmpjcj > 80 && s[i].Lw >= 1) s[i].Jxj += 8000; if(s[i].Qmpjcj > 85 && s[i].Bjpycj > 80) s[i].Jxj += 4000; if(s[i].Qmpjcj > 90) s[i].Jxj += 2000; if(s[i].Qmpjcj > 85 && s[i].Xb == 'Y') s[i].Jxj += 1000; if(s[i].Bjpycj > 80 && s[i].Gb == 'Y') s[i].Jxj += 850; Sum += s[i].Jxj; if(Max < s[i].Jxj){ Max = s[i].Jxj; Wz = i; } } printf("%s\n%d\n%d\n",s[Wz].name,s[Wz].Jxj,Sum); } return 0; }
标签:style io ar color os sp for 文件 数据
原文地址:http://blog.csdn.net/yzi_angel/article/details/41481557