C/C++の宿題を片付けます 100at TECH
C/C++の宿題を片付けます 100 - 暇つぶし2ch246:デフォルトの名無しさん
07/11/26 22:25:25
>>240
#include <stdio.h>
#define N 10

void subfunc(int cnt, int *num, int *ans){
int i, k, pos;
for(i=0; i<cnt; i++){
for(k=1, pos=0; k<cnt; k++){
if(num[pos] < num[k])pos = k;
}
ans[i] = num[pos];
num[pos] = 0;
}
}

int main(void){
int i, num[N], ans[N], sum=0;
for(i=0; i<N; i++){
printf("%d個目->", i+1);
scanf("%d", &num[i]);
}
subfunc(N, num, ans);
for(i=0; i<N; i++){
printf("%d ", ans[i]);
sum += ans[i];
}
printf("\n中央値:%d\n", sum/N);
return 0;
}



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch