anonymous No title
No License C++
2020年09月11日
Copy
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

int main() {
	double sum, ave, max, sd, devi;
	int count;
	int rand_nums [10];

	//変数初期化
	sum = 0, ave = 0, max = 0, sd = 0, devi = 0;

	//乱数配列 --1から100の乱数--
	for (count = 0; count < 10; count++) {
		rand_nums [count] = rand() % 100 +1;
	}

	//##############################################################

	//合計
	for (count = 0; count < 10; count++) {
		sum += rand_nums [count];
	}

	//平均
	ave = sum / 10;

	//最大
	max = rand_nums[0];
	for (count = 1; count < 10; count++) {
		if (max < rand_nums [count]) {
			max = rand_nums[count];
		}
	}

	//標準偏差
	for (count = 0; count < 10; count++) {
		devi += pow((rand_nums [count] - ave),2);
	}
	sd = sqrt(devi / 10);

	//##############################################################

	//表示
	printf("乱数:");
	for (count = 0; count < 10; count++) {
		printf("%d,", rand_nums [count]);
	}
	printf("\n合計:%lf\n平均:%lf\n最大:%lf\n標準偏差:%lf\n", sum, ave, max, sd);

	return 0;
}
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

int main() {
	double sum, ave, max, sd, devi;
	int count;
	int rand_nums [10];

	//変数初期化
	sum = 0, ave = 0, max = 0, sd = 0, devi = 0;

	//乱数配列 --1から100の乱数--
	for (count = 0; count < 10; count++) {
		rand_nums [count] = rand() % 100 +1;
	}

	//##############################################################

	//合計
	for (count = 0; count < 10; count++) {
		sum += rand_nums [count];
	}

	//平均
	ave = sum / 10;

	//最大
	max = rand_nums[0];
	for (count = 1; count < 10; count++) {
		if (max < rand_nums [count]) {
			max = rand_nums[count];
		}
	}

	//標準偏差
	for (count = 0; count < 10; count++) {
		devi += pow((rand_nums [count] - ave),2);
	}
	sd = sqrt(devi / 10);

	//##############################################################

	//表示
	printf("乱数:");
	for (count = 0; count < 10; count++) {
		printf("%d,", rand_nums [count]);
	}
	printf("\n合計:%lf\n平均:%lf\n最大:%lf\n標準偏差:%lf\n", sum, ave, max, sd);

	return 0;
}

年末年始は機械学習・深層学習を勉強しませんか?
No one still commented. Please first comment.
年末年始は機械学習・深層学習を勉強しませんか?
広告
未経験から最短でエンジニアへの転職を目指すなら