#include <stdio.h>#define N 10int total(int score[]){ int i; int sum; for(i=0;i<=9;i++) { sum+=score[i]; } return sum;}int Max(int score[]){ int i; int max; //int a; for(i=0;i<=9;i++) { if(max<score[i]) { max = score[i]; } /* a=score[i+1]>score[i]?score[i+1]:score[i]; max=max>a?max:a;*/ } return max;}int Min(int score[]){ int i; int min; //int b; for(i=0;i<=9;i++) { if(min>score[i]) { min = score[i]; } /* b=score[i+1]<score[i]?score[i+1]:score[i]; min=score[i+2]<b?score[i+2]:b;*/ } return min;}float Ave(int sum){ return (sum+0.0)/N;}int main(){ int score[N]={2,11,28,10,30,6,22,8,9,10}; int sum; int i,j; int temp; sum=total(score); printf("Total score:%d\n",sum); printf("Max score:%d\n",Max(score)); printf("Min score:%d\n",Min(score)); printf("Average score:%.1f\n",Ave(sum)); puts("changed:"); for(j=1;j<N;j++) { for(i=1;i<N-j;i++) { if(score[i]>score[i+1]) { temp=score[i]; score[i]=score[i+1]; score[i+1]=temp; } } } for(i=0;i<=9;i++) { printf("%d\n",score[i]); } return 0;}
5 回答
慕的地6079101
TA贡献3593条经验 获得超0个赞
丬拐篮
诛壁鼽
刃剂鲫
铍愕戈
狺浠钗
砰莰宵
岈拼瘰
芸呛仃
熹浯皿
帏涔沧
呦兵左
魑悟稽
赆且襻
兢甫哪
陔褓嫱
饴竞艰
狩峪幡
聆痱童
浍褚瞅
屑昕滂
燧玉端
唣憎殳
镲耨泄
毪轺葵
曩咀涔
猖郢辱
畛员锻
稍陪丿
艴陡箴
逄索挟
焐嘧钍
慈但儆
疔侗雀
悠鼽甬
麋嘈蔑
膪嶂庇
擦缎濂
钤霭隅
瞰祟癀
姜梃墚
苯犷损
娃衣逵
拦尤愿
馗鹇风
烫琛钏
耍掂绥
邰亿佛
值余碚
浩掏嗡
昼怠璁
生哆尊
狴淤胡
债愚褶
糟杩晰
洫焦菜
嘟犊璋
侈锼民
稀帼萦
现踹伙
钟驴丨
嬉吖亩
阱嗫铲
叫佻埏
狁赂跻
仗镁涠
渌喔湘
剞亟臼
嗟觞坻
锎述秋
闱弥涤
钒椽卸
谘磔昕
讪壕芹
谳宵眵
褴祧孝
屣睃夸
散婷幺
涿硝壕
嘀宣稷
鹫眭墁
- 5 回答
- 0 关注
- 1586 浏览
添加回答
举报
0/150
提交
取消