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

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

為何最后輸出排序的時(shí)候有個(gè)大數(shù)字的垃圾數(shù)字?


#include <stdio.h>

#define N 10

int scoreSum(int score[])

{

? ? int i;

? ? int sum = 0;

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

? ? {

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

? ? }

? ? return sum;?

}


int scoreMax(int score[])

{

? ? int i,max;

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

? ? {

? ? ? ? max = score[0];

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

? ? ? ? max = score[i];

? ? }

? ? return max;

? ??

}


int scoreMin(int score[])

{

? ? int i,min;

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

? ? {

? ? ? ? min = score[0];

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

? ? ? ? min = score[i];

? ? }

? ? return min;

}


int scoreAvg(int score[])

{

? ? int i;

? ? int sum = 0;

int avg = 0;

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

? ? {

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

? ? }

? ? avg = sum/N;

? ? return avg;?

}


int bubbleSort(int score[])

{

? ? int i,j;

? ? int temp=0;

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

? ? {

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

? ? ? ? {

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

? ? ? ? ? ? {

? ? ? ? ? ? ? ? temp = score[j];

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

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

? ? ? ? ? ? }

? ? ? ? }

? ? }

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

? ? {

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

? ? }

return 0;

}


int main()

{

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

? ? int sum,avg,max,min;

sum = scoreSum(score);

avg = scoreAvg(score);

max = scoreMax(score);

min = scoreMin(score);

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

printf("平均分是:%d\n",avg);

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

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

? ? bubbleSort(score);

? ? return 0;

}


正在回答

1 回答

score[j]<score[j+1];當(dāng)j=9,時(shí)沒(méi)有定義score[10],而且最大最小輸出不對(duì)。

#include <stdio.h>

#define N 10

int scoreSum(int score[])

{

? ? int i;

? ? int sum = 0;

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

? ? {

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

? ? }

? ? return sum;?

}


int scoreMax(int score[])

{

? ? int i,max;

? ? ?max = score[0];

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

? ? {

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

? ? ? ? max = score[i];

? ? }

? ? return max;

? ??

}


int scoreMin(int score[])

{

? ? int i,min;

? ? ?min = score[0];

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

? ? {

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

? ? ? ? min = score[i];

? ? }

? ? return min;

}


int scoreAvg(int score[])

{

? ? int i;

? ? int sum = 0;

int avg = 0;

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

? ? {

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

? ? }

? ? avg = sum/N;

? ? return avg;?

}


int bubbleSort(int score[])

{

? ? int i,j;

? ? int temp=0;

? ? ? ? for(j=0;j<N-1;j++)

? ? ? ? {

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

? ? ? ? ? ? {

? ? ? ? ? ? ? ? temp = score[j];

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

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

? ? ? ? ? ? }

? ? ? ? }

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

? ? {

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

? ? }

return 0;

}


int main()

{

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

? ? int sum,avg,max,min;

sum = scoreSum(score);

avg = scoreAvg(score);

max = scoreMax(score);

min = scoreMin(score);

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

printf("平均分是:%d\n",avg);

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

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

? ? bubbleSort(score);

? ? return 0;

}


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

向上爬的魚(yú) 提問(wèn)者

非常感謝!
2016-03-07 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為何最后輸出排序的時(shí)候有個(gè)大數(shù)字的垃圾數(shù)字?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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