趣味编程4.c

//  歌星大奖赛:
//  在歌星大奖赛中,有10个评委为参赛选手打分,分数从1~100分。
//  选手最后得分为:去掉一个最高分和一个最低分其余8个分数的平均值。

/*	问题分析与算法设计
		这个问题的算法十分简单,
		但要注意在程序中判断最大最小值的变量是如何赋值的。
*/

#include <stdio.h>

int main()
{
	float score = 0;
	float max = 0;
	float min = 100;
	float sum = 0;
	int i;
	
	for (i = 1; i <= 10; i++)
	{
		printf ("Input number %d = ",i);
		scanf ("%f",&score);
		sum += score;
		if (score > max)
			max = score;
		if (score < min)
			min = score;
	}
	
	printf ("Canceled max score:%f\nCanceled min score:%f\n",
			max,min);
	printf ("Average score:%.3f\n",(sum-max-min)/8);
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_40383812/article/details/84490814