① 代码:
#include
int main(int argc, char const *argv[])
{
double score, highest, lowest;
int n;
highest = -1; lowest = 1000000000;
n = 0;
while(1) {
scanf("%lf", &score);
if (score < 0.0) break;
if (highest < score) highest = score;
if (lowest > score) lowest = score;
n++;
}
printf("Total %d:\n", n);
printf(" The highest score is : %6.2f\n", highest);
printf(" The lowest score is : %6.2f\n", lowest);
return 0;
}
② 运行:
100 60 92.5 80.5 50.8 -1
Total 5:
The highest score is : 100.00
The lowest score is : 50.80