c语言程序设计数组方面
其他问答
1
10人成绩放在score数组中 编写程序,将不及格的人数,最低分和最高分显示出来
-
#include<stdio.h> #define N 10 int main() { float score[N]; printf("input scores:"); for (int i = 0; i < N; i++) { scanf("%f", &score[i]); } float maxScore = score[0], minScore = score[0]; int count = 0; for (i = 0; i < N; i++) { if (score[i] > maxScore) { maxScore = score[i]; } if (score[i] < minScore) { minScore = score[i]; } if (score[i] < 60) { count++; } } printf("最高分: %f, 最低分: %f, 不及格人数:%d\n", maxScore, minScore, count); return 0; }
-
#define N 10 int main() { float score[N]; printf("input scores:"); for (int i = 0; i < N; i++) { scanf("%f", &score[i]); } float maxScore = score[0], minScore = score[0]; int count = 0; for (i = 0; i < N; i++) { if (score[i] > maxScore) { maxScore = score[i]; } if (score[i] < minScore) { minScore = score[i]; } if (score[i] < 60) { count++; } } printf("最高分: %f, 最低分: %f, 不及格人数:%d\n", maxScore, minScore, count); return 0; }
发表回复