Created
November 30, 2012 11:08
-
-
Save alphaKAI/4175160 to your computer and use it in GitHub Desktop.
こんなんじゃねーのかな
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* @meganenonattu : 「10個の数字を入力して、その数値を順番通りに出力すること。 | |
また、最後に数値の合計と平均を出力すること。(平均は小数まで表示させること)」だね */ | |
int main(void){ | |
/* forの変数i */ | |
int i; | |
/* ユーザー入力 */ | |
int num[10]; | |
/* 合計値 */ | |
int num2 = 0; | |
/* 平均値 */ | |
double sum; | |
printf("10この数字を入力してその値を入力した順番に並び替え、合計値・平均値を出力します\n"); | |
for(i=0; i<=9; i++){ | |
printf("%dこ目の数字を入力してください\n", i+1); | |
scanf("%d", &num[i]); | |
num2 += num[i]; | |
} | |
sum=(double)num2/10; | |
printf("値を出力します\n"); | |
for(i=0; i<=9; i++){ | |
printf("%d\n", num[i]); | |
} | |
printf("合計値: %d\n", num2); | |
printf("平均値: %lf\n", sum); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment