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

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

求大佬幫忙看看是哪里錯了。。后兩個函數的結果有問題

#include <stdio.h>

int sum;

int getsum(int score[])

? ? {? ?int i;

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

? ? ? ? {

? ? ? ? ? ??

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

? ? ? ? }

? ? ? ? printf("考試的總分為%d\n",sum);

? ? }



void getmax(int score[])

? ? {? ?int i;

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

? ? ? ? {

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

? ? ? ? ? ? {? ?int temp;

? ? ? ? ? ? ? ? temp=score[i];

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

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

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? int max=score[9];

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

? ? }

void getmin(int score[])

? ? {? ?int i;

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

? ? ? ? {

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

? ? ? ? ? ? {? ?int temp;

? ? ? ? ? ? ? ? temp=score[i];

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

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

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? int min=score[9];

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

? ? }

int getaverage(n)

? ? {? ?

? ? ? ? printf("平均分為%d",n/10.0);

? ? ? ? return 0;

? ? }

void rank(int score[])

? ? {? ?int i,j;

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

? ? ? ? {

? ? ? ? ? ? for(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(i=0;i<=9;i++);

? ? ? ? {

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

? ? ? ? }

? ? ? ??

? ? }

int main()

{

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

? ? getsum(score);

? ? getmax(score);

? ? getmin(score);

? ? getaverage(sum);

? ? rank(score);

? ? return 0;

}


正在回答

1 回答

考試的總分為786
最高分為98
最低分為63
平均分為-7984875311777852389

這是結果

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

舉報

0/150
提交
取消

求大佬幫忙看看是哪里錯了。。后兩個函數的結果有問題

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

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

幫助反饋 APP下載

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

公眾號

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