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