第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

在一個(gè)長(zhǎng)度為10的整型數(shù)組里面,保存了班級(jí)10個(gè)學(xué)生的考試成績(jī)。要求編寫(xiě)5個(gè)函數(shù),分別實(shí)現(xiàn)計(jì)算考試的總分,最高分,最低分,平均分和考試成績(jī)降序排序。

#include <stdio.h>
int main()
{
int score[]={67,98,75,63,82,79,81,91,66,84};
int num;
int all;
int i;
int j;
int qw;
for(num=0,all=0;num<10;num++)
{
all+=score[num];
}
printf("這次考試十個(gè)學(xué)生的總分是%d。\n",all);
printf("這次考試的平均分是%.1f。\n",all/10.0);
for(qw=0;qw<=10;qw++)
{
for(j=0;j<=9;)
{
if(score[j]<score[j+1])
{
i=score[j+1];
score[j+1]=score[j];
score[j]=i;
}
j+=1;
}
}
printf("這次考試最高分是%d。\n",score[0]);
printf("這次考試最低分是%d。\n",score[9]);
printf("這次考試按排名排是 ");
for(i=0;i<=9;i++)
{
printf("第%d名:%d分。",i+1,score[i]);
}
return 0;
}

正在回答

1 回答

#include?<stdio.h>
#define?N?10
void?number(int?score[])
{
?int?i;
?printf("\n");
?for(i=0;i<N;i++)
?{
??printf("%d",score[i]);
?}
?printf("\n");
}
int?sum(int?score[])
{
????int?i,sum=0;
????for(i=0;i<N;i++)
????{
????????sum+=score[i];
????}
????return?sum;
}
int?maxscore(int?score[])
{
????int?i,max=-1;
????for(i=1;i<N;i++)
????{
????????if(max<score[i])
????????max=score[i];
????}
????return?max;
}
int?minscore(int?score[])
{
????int?i;
?int?min=100;
????for(i=1;i<N;i++)
????{
????????if(min>score[i])
????????min=score[i];
????}
????return?min;
}
int?average(int?score[],int?n)
{
????return?sum(score)/N;
}
void?sort(int?score[])
{
????int?i,j,temp;
????for(i=N-2;i>=0;i--)
????{
????????for(j=0;j<=i;j++)
????????{
????????????if(score[j]<score[j+1])
????????????{
?????????????temp=score[j];
?????????????score[j]=score[j+1];
?????????????score[j+1]=temp;
????????????}
????????}
????}
????number(score);
}
int?main()
{
????int?score[N]={67,98,75,63,82,79,81,91,66,84};
????printf("最高分為%d\n",maxscore(score));
????printf("最低分為%d\n",minscore(score));
????printf("總分為%d\n",sum(score));
????printf("平均分為%d\n",average(score,N));
????sort(score);
????return?0;
}


1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

在一個(gè)長(zhǎng)度為10的整型數(shù)組里面,保存了班級(jí)10個(gè)學(xué)生的考試成績(jī)。要求編寫(xiě)5個(gè)函數(shù),分別實(shí)現(xiàn)計(jì)算考試的總分,最高分,最低分,平均分和考試成績(jī)降序排序。

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)