@sensitive-cs
2016-10-19T16:01:42.000000Z
字数 534
阅读 959
有n个人,m个学科,每个学科都有分数最高的学生,即successful-student,找出这种学生的人数。
首先找出每科成绩的最高分,接着寻找每科成绩的最高分得者,当某个学生被记入后,此学生的所有成绩清空,然后继续寻找,直到找到最后一个为止。
#include <stdio.h>#include <string.h>char a[110][110];char max[110];int main(){int stu,sub;int i,j,sum = 0;for (i = 0;i < 110;i++)max[i] = '0';scanf("%d%d",&stu,&sub);getchar();for (i = 1;i <= stu;i++)scanf("%s",a[i]);for (j = 0;j < sub;j++)for (i = 1;i <= stu;i++){if (a[i][j] >= max[j])max[j] = a[i][j];}for (j = 0;j <sub;j++)for (i = 1;i <= stu;i++){if (a[i][j] == max[j]){sum++;memset(a+i,'0',sizeof(char)*110);}}printf("%d\n",sum);return 0;}
