亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

跪求兄弟姐妹來看看我的程序為什么沒有輸出??明明沒有報錯,邏輯也感覺沒有問題

#include <stdio.h>

int main()

{

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

? ? void allgrade();

? ? void mostgrade();

? ? void lowgrade();

? ? void average();

? ? void gradedown();

? ? ?

? ? return 0;

}

void allgrade()

{

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

? ? int i;

? ? int temp;

? ? int sum=0;

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

? ? {

? ? ? ? temp=score[i];

? ? ? ? sum=temp+sum;

? ? }

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

}

void mostgrade()

{

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

? ? int store;

? ? int i;

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

? ? {

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

? ? ? ? {

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

? ? ? ? ? ? store=score[i+1];

? ? ? ? }

? ? }

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

}

void lowgrade()

{

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

? ? int story;

? ? int i;

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

? ? {

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

? ? ? ? {

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

? ? ? ? story=score[i+1];

? ? ? ? }

? ? }

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

}

void average()

{

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

? ? int i;

? ? int temp;

? ? int sum=0;

? ? int average1;

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

? ? {

? ? ? ? temp=score[i];

? ? ? ? sum=temp+sum;

? ? }

? ? average1=sum/10;

? ? printf("平均分%d\n",average1);

}

void gradedown()

{

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

? ? int store;

? ? int i;

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

? ? {

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

? ? ? ? {

? ? ? ? ? ? ?store=score[i+1];

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

? ? ? ? ? ? score[i]=store;

? ? ? ? }

? ? }

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

? ? {

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

? ? }

}


正在回答

2 回答

不用跪求...解決了問題記得采納回答者就行了!

//第一:將你定義的四個函數放到到main函數之前
//第二:調用函數不用加void前綴
#include?<stdio.h>
void?allgrade()
{
????int?score[10]={67,98,75,63,82,79,81,91,66,84};
????int?i;
????int?temp;
????int?sum=0;
????for(i=0;i<10;i++)
????{
????????temp=score[i];
????????sum=temp+sum;
????}
????printf("總分%d?\n",sum);
}
void?mostgrade()
{
int?score[10]={67,98,75,63,82,79,81,91,66,84};
????int?store;
????int?i;
????for(i=0;i<9;i++)
????{
????????if(score[i]>score[i+1])
????????{
????????????score[i+1]=score[i];
????????????store=score[i+1];
????????}
????}
????printf("最高分是%d\n",store);
}
void?lowgrade()
{
int?score[10]={67,98,75,63,82,79,81,91,66,84};
????int?story;
????int?i;
????for(i=0;i<9;i++)
????{
????????if(score[i]<score[i+1])
????????{
????????score[i+1]=score[i];
????????story=score[i+1];
????????}
????}
???	printf("最低分是%d\n",story);
}
void?average()
{
int?score[10]={67,98,75,63,82,79,81,91,66,84};
????int?i;
????int?temp;
????int?sum=0;
????int?average1;
????for(i=0;i<10;i++)
????{
????????temp=score[i];
????????sum=temp+sum;
????}
????average1=sum/10;
????printf("平均分%d\n",average1);
}
void?gradedown()
{
????int?score[10]={67,98,75,63,82,79,81,91,66,84};
????int?store;
????int?i;
????for(i=0;i<9;i++)
????{
????????if(score[i]>score[i+1])
????????{
?????????????store=score[i+1];
????????????score[i+1]=score[i];
????????????score[i]=store;
????????}
????}
????for(i=0;i<9;i++)
????{
????????printf("%d??,",score[i]);
????}
}
int?main()
{
????int?score[10]={67,98,75,63,82,79,81,91,66,84};
?????allgrade();
?????mostgrade();
?????lowgrade();
?????average();
?????gradedown();
?????
????return?0;
}


1 回復 有任何疑惑可以回復我~
#1

慕后端9788028 提問者

程序后來我改了下,改對了。但是有點疑惑,為什么要把函數放在定義的主函數前面呢?如果在后面,是不是因為函數是是從主函數開始執行,如果把定義的函數放后面,程序讀到return 0;就不往下讀了?如果是在前面,程序會把記下定義的函數,然后從主函數開始執行??? 還有,為什么主函數已經定義了數組的情況下,在自定義函數中不重新定義一次數組,程序會報錯?? 還有上面的降序排列我寫錯了,不過已經改了
2016-09-15 回復 有任何疑惑可以回復我~
#2

JustWannaHugU 回復 慕后端9788028 提問者

意思是我回答完你上面所有問題,你才能采納我? 對不起,我時間沒那么廉價
2016-09-15 回復 有任何疑惑可以回復我~
#3

慕后端9788028 提問者 回復 JustWannaHugU

我不知道你生活中說話是不是這個樣子?  別人也不是那個意思,干嘛要這樣說話,大家都是剛接觸C語言,有不明白的地方也很正常,你也可以選擇無視掉,網上這樣很正常,但不該說傷人的話。對人不尊重,這就不應該了。
2016-09-15 回復 有任何疑惑可以回復我~

當然不是,采納這個很重要嗎?

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

跪求兄弟姐妹來看看我的程序為什么沒有輸出??明明沒有報錯,邏輯也感覺沒有問題

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號