c语言编写最高分和最低分
答案:1 悬赏:40
解决时间 2021-01-23 10:45
- 提问者网友:不要迷恋哥
- 2021-01-22 20:27
c语言编写最高分和最低分
最佳答案
- 二级知识专家网友:上分大魔王
- 2021-01-22 20:56
#include
#define STUDENT_COUNT 40 //定义学生数目
int main()
{
int student_score[STUDENT_COUNT], max_score = 0, min_score = 100;
srand(unsigned(time(NULL)));
for (int i = 0; i < STUDENT_COUNT; i++)
{
scanf("%d", &student_score[i]);
}
for (int i = 0; i < STUDENT_COUNT; i++)
{
if (max_score < student_score[i])
{
max_score = student_score[i];
}
if (min_score > student_score[i])
{
min_score = student_score[i];
}
}
printf("max score : %d, min score : %d
", max_score, min_score);
return 0;
}
//测试样例
//2
//4
//32
//91
//58
//67
//69
//31
//12
//88
//35
//40
//80
//87
//35
//61
//11
//67
//87
//67
//28
//70
//51
//8
//0
//50
//82
//25
//99
//74
//24
//48
//79
//85
//51
//13
//86
//19
//2
//41
//max score : 99, min score : 0
#define STUDENT_COUNT 40 //定义学生数目
int main()
{
int student_score[STUDENT_COUNT], max_score = 0, min_score = 100;
srand(unsigned(time(NULL)));
for (int i = 0; i < STUDENT_COUNT; i++)
{
scanf("%d", &student_score[i]);
}
for (int i = 0; i < STUDENT_COUNT; i++)
{
if (max_score < student_score[i])
{
max_score = student_score[i];
}
if (min_score > student_score[i])
{
min_score = student_score[i];
}
}
printf("max score : %d, min score : %d
", max_score, min_score);
return 0;
}
//测试样例
//2
//4
//32
//91
//58
//67
//69
//31
//12
//88
//35
//40
//80
//87
//35
//61
//11
//67
//87
//67
//28
//70
//51
//8
//0
//50
//82
//25
//99
//74
//24
//48
//79
//85
//51
//13
//86
//19
//2
//41
//max score : 99, min score : 0
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯