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

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

有人可以耐心看下代碼錯(cuò)誤嗎

#include <stdio.h>

int sum(int score[10])

{

? ? int sums,i;

? ? for(i=0;i<10;i++)

? ? {

? ? ? ? sums+=score[i];

? ? }

? ? return sums;

}

int max(int score[10])

{

? ? int maxs=0,i;

? ? for(i=0;i<10;i++)

? ? {

? ? ? ? if (maxs<score[i])

? ? ? ? {

? ? ? ? ? ? maxs=score[i];

? ? ? ? }

? ? }

? ? return maxs;

}

int min(int score[10])

{

? ? int mins=max(score),i;

? ? for(i=0;i<10;i++)

? ? {

? ? ? ? if (mins>score[i])

? ? ? ? {

? ? ? ? ? ? mins=score[i];

? ? ? ? }

? ? }

? ? return mins;

}

int ave(int score[10])

{

? ? int aves;

? ? aves=(sum(score))/10;

? ? return aves;

}

void a(int score[10])

{

? ? int i,j,flag;

? ? for(i=9;i>=0;i--)

? ? {

? ? ? ? for (j=0;j<=9;j++)

? ? ? ? {

? ? ? ? ? ? if (score[j]<score[j+1])

? ? ? ? ? ? {

? ? ? ? ? ? ? ? flag=score[j];

? ? ? ? ? ? ? ? score[j]=score[j+1];

? ? ? ? ? ? ? ? score[j+1]=flag;

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ? for(i=0;i<10;i++)

? ? {

? ? ? ? if (i!=9)

? ? ? ? {

? ? ? ? ? ? printf("%d ",score[i]);

? ? ? ? }

? ? ? ? else?

? ? ? ? {

? ? ? ? ? ? printf("%d\n",score[i]);

? ? ? ? }

? ? }

}

int main()

{

? ? int score[10]={67,98,75,63,82,79,81,91,66,84};

? ? printf("總分是%d\n",sum(score));

? ? printf("最高分是%d\n",max(score));

? ? printf("最低分是%d\n",min(score));

? ? printf("平均分是%d\n",ave(score));

? ? a(score);

? ? return 0;

}


正在回答

2 回答

你的問(wèn)題出在:沒(méi)有定義局部變量sums的值。

你應(yīng)該將 int sums,i; 改為 int sums=0,i;

如果你不定義局部變量sums的值,其值在你輸出總分時(shí)已經(jīng)儲(chǔ)存在內(nèi)存中,當(dāng)你再次使用sums,它的值默認(rèn)不為0,那么它的值不確定,因此平均數(shù)輸出值發(fā)生錯(cuò)誤。


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

Poplar_Y

你可以試著按我說(shuō)的修改,感受一下問(wèn)題。
2019-10-29 回復(fù) 有任何疑惑可以回復(fù)我~
#2

qq_慕用5232731 回復(fù) Poplar_Y

平均數(shù)的計(jì)算過(guò)程中有sums么?求大佬解答
2020-02-07 回復(fù) 有任何疑惑可以回復(fù)我~

#include <stdio.h>


int sum(int score[10])


{


? ? int sums,i;


? ? for(i=0;i<10;i++)


? ? {


? ? ? ? sums+=score[i];


? ? }


? ? return sums;


}


int max(int score[10])


{


? ? int maxs=0,i;


? ? for(i=0;i<10;i++)


? ? {


? ? ? ? if (maxs<score[i])


? ? ? ? {


? ? ? ? ? ? maxs=score[i];


? ? ? ? }


? ? }


? ? return maxs;


}


int min(int score[10])


{


? ? int mins=max(score),i;


? ? for(i=0;i<10;i++)


? ? {


? ? ? ? if (mins>score[i])


? ? ? ? {


? ? ? ? ? ? mins=score[i];


? ? ? ? }


? ? }


? ? return mins;


}


int ave(int score[10])


{


? ? int aves;


? ? aves=(sum(score))/10;


? ? return aves;


}


void a(int score[10])


{


? ? int i,j,flag;


? ? for(i=8;i>=0;i--)


? ? {


? ? ? ? for (j=0;j<=i;j++)


? ? ? ? {


? ? ? ? ? ? if (score[j]>score[j+1])


? ? ? ? ? ? {


? ? ? ? ? ? ? ? flag=score[j];


? ? ? ? ? ? ? ? score[j]=score[j+1];


? ? ? ? ? ? ? ? score[j+1]=flag;


? ? ? ? ? ? }


? ? ? ? }


? ? }


? ? for(i=9;i>=0;i--)


? ? {


? ? ? ? if (i!=0)


? ? ? ? {


? ? ? ? ? ? printf("%d ",score[i]);


? ? ? ? }


? ? ? ? else?


? ? ? ? {


? ? ? ? ? ? printf("%d\n",score[i]);


? ? ? ? }


? ? }


}


int main()


{


? ? int score[10]={67,98,75,63,82,79,81,91,66,84};


? ? printf("總分是%d\n",sum(score));


? ? printf("最高分是%d\n",max(score));


? ? printf("最低分是%d\n",min(score));


? ? printf("平均分是%d\n",ave(score));


? ? a(score);


? ? return 0;


}


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

舉報(bào)

0/150
提交
取消

有人可以耐心看下代碼錯(cuò)誤嗎

我要回答 關(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)