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

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

求解答啊 不知道哪錯了 運(yùn)行不出來

#include <stdio.h>

int main()

{

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

? ? int total = fun1(score);

? ? int max = fun2(score);

? ? int min = fun4(score);

? ? int average = total/10;

? ? fun3(score);

? ? printf("%d",max);

? ? printf("%d",min);

? ? printf("%d",total);

? ? printf("%d",average);

? ? return 0;

}


int fun1(int score[]){

? ? int total = 0;

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

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

? ? }

? ? return total;

}


int fun2(int score[]){

? ? int max;

? ? for(int i=0;i<9;i++){

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

? ? ? ? ? ? max = score[i];

? ? ? ? }

? ? }

? ? return max;

}


int fun4(int score[]){

? ? int min;

? ? for(int i=0;i<9;i++){

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

? ? ? ? ? ? min = score[i];

? ? ? ? }

? ? }

? ? return min;

}


void fun3(int score[]){

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

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

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

? ? ? ? ? ? ? ? int temp;

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

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

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

? ? ? ? ? ? }

? ? ? ? }

? ? }

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

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

? ? }

}


正在回答

3 回答

求最大值、最小值等幾個函數(shù)判斷循環(huán)結(jié)束的條件應(yīng)該為i<10或i<=9

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

必須先聲明函數(shù),然后才能調(diào)用函數(shù),而且數(shù)組里的N是不用加的,放在編譯器里是錯誤的,因?yàn)镹并未聲明,慕課網(wǎng)的代碼運(yùn)行有一點(diǎn)問題,換成下邊在編譯器運(yùn)行是可以的,希望可以幫助到你。


#include <stdio.h>

int fun1(int score[]){

? ? int total = 0;

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

? ? {

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

? ? }

? ? return total;

}

int fun2(int score[]){

int max=score[0];

? ? for(int i=0;i<9;i++)

? ? {

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

? ? ? ? {

? ? ? ? ? ? max = score[i];

? ? ? ? }

? ? }

? ? return max;

}

int fun4(int score[]){

? ? int min=score[0];

? ? for(int i=0;i<9;i++){

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

? ? ? ? ? ? min = score[i];

? ? ? ? }

? ? }

? ? return min;

}

void fun3(int score[]){

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

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

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

? ? ? ? ? ? ? ? int temp;

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

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


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

? ? ? ? ? ? }

? ? ? ? }

? ? }

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

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

? ? }

? ? printf("\n");

}

int main()

{??

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

? ? int total = fun1(score);

? ? int max = fun2(score);

? ? int min = fun4(score);

? ? int average = total/10;

? ? fun3(score);

? ? printf("%d\n",max);

? ? printf("%d\n",min);

? ? printf("%d\n",total);

? ? printf("%d\n",average);

? ? return 0;

}


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

除了循環(huán)條件外,還有在函數(shù)實(shí)現(xiàn)的時(shí)候int score[N]是不對的,改成int score[]就好了

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

舉報(bào)

0/150
提交
取消

求解答啊 不知道哪錯了 運(yùn)行不出來

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

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

幫助反饋 APP下載

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

公眾號

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