c语言 在歌星大奖赛,C语言 歌星大奖赛为参赛的选手打分
歌星大獎賽為參賽的選手打分
C語言歌星大獎賽為參賽的選手打分
在歌星大獎賽中,有 10 個評委為參賽的選手打分,分數為 1~100 分。選手最后得分為:去掉
一個最高分和一個最低分后其余 8 個分數的平均值。請編寫一個程序實現。 *問題分析與算法設計
問題分析與算法設計
問題分析與算法設計
問題分析與算法設計
這個問題的算法十分簡單,但是要注意在程序中判斷最大、最小值的變量是如何賦值的。 *程序說明與注釋
#include
int main()
{
int integer,i,max,min,sum;
max=-32768; /*先假設當前的最大值 max 為 C 語言整型數的最小值*/ min=32767; /*先假設當前的最小值 min 為 C 語言整型數的最大值*/ sum=0; /*將求累加和變量的初值置為 0*/
for(i=1;i<=10;i++)
{
printf("Input number %d=",i);
scanf("%d",&integer); /*輸入評委的評分*/
sum+=integer; /*計算總分*/
if(integer>max)max=integer; /*通過比較篩選出其中的最高分*/
if(integer
}
printf("Canceled max score:%d\nCanceled min score:%d\n",max,min);
printf("Average score:%d\n",(sum-max-min)/8); /*輸出結果*/
}
*運行結果
運行結果
運行結果
運行結果
Input number1=90
Input number2=91
Input number3=93
Input number4=94
Input number5=90
Input number6=99
Input number7=97
Input number8=92
新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!總結
以上是生活随笔為你收集整理的c语言 在歌星大奖赛,C语言 歌星大奖赛为参赛的选手打分的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MTM:matlab实现2参数解析
- 下一篇: MTM:matlab实现3谱功率计算