請用C++亂數~N(70,10)產生100個隨機亂數
寫進csv檔
herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
計算你的BMI
-
1. 利用遞迴input n算2^n 2. 用C算GCD(3333,456)
-
請用 C/C++/java寫一簡易程式
-
一、 試利用switch case由程式中直接輸入一個1~7 之間的整數day,代表星期一到星期日。若day 的值是1,則印出 "星期一",若day 的值是2,則印出 "星期二",若day 的值是7,則印出 "星期日",...
-
33, 45, 87, 99, 27 算平均
-
BMI (Body Mass Index)= 體重 (kg) / 身高 ^2(m 2 ) 在台灣,行政院衛生署乃根據其相關研究,於2002年4月公佈台灣成人肥胖標準: BMI<18.5 為過輕, 18.5≦BMI<24 為正常體重, 24≦BMI<27 為過重, BM...
-
需要練習的Java程式:
-
用 C/C++算上學期加權平均
20 則留言:
#include<fstream>
#include <iostream>
#include<cstdlib>
#include<random>
#include<ctime>
#include<cmath>
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
#include<iostream>
#include<cstdlib>
#include<random>
#include<ctime>
#include<fstream>
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> x(70, 10);
int a[1000];
double s = 0;
for (int i = 0; i < 100; i++){
a[i] = x(gen);
cout << a[i] << "\t";
fout << a[i]<<",\n";
s = a[i]+s;
if (i % 10 == 9)cout << endl;
}
fout.close();
system("Pause");
return 0;
}
#include<fstream>
#include <iostream>
#include<cstdlib>
#include<random>
#include<ctime>
#include<cmath>
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
#include<fstream>
#include <iostream>
#include<cstdlib>
#include<random>
#include<ctime>
#include<cmath>
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
#include
#include
#include
using namespace std;
int main(){
fstream fout;
fout.open("test.csv", ios::out | ios::trunc);
fout << "hello, 1,2,3\n";
fout << "hello, 2,2,4\n";
fout.close();
system("Pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv",ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
fout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)fout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
fout << (clock()-seed)/1000.0 <<"sec." << endl;
system("Pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
fout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)fout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
fout << (clock() - seed) / 1000.0 << "sec." << endl;
system("Pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
fout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)fout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
fout << (clock() - seed) / 1000.0 << "sec." << endl;
system("Pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <random>
#include <ctime>
#include <cmath>
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
cout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)cout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
cout << (clock() - seed) / 1000.0 << "sec." << endl;
system("Pause");
return 0;
}
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<random>
#include<ctime>
using namespace std;
int main(){
fstream fout;
fout.open("test.csv", ios::out | ios::trunc);
int test = clock();
mt19937_64 gen(test);
normal_distribution<double>dis(70, 10);
int a[100];
for (int i = 0; i < 100; i++){
a[i] = (int)(round(dis(gen)));
fout << a[i] << "\n";
}
fout.close();
fout << endl;
system("Pause");
return 0;
}
#include
#include
#include
#include
#include
#include
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
#include
#include
#include
#include
#include
#include
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
#include
#include
#include
#include
#include
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv",ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
fout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)fout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
fout << (clock()-seed)/1000.0 <<"sec." << endl;
system("Pause");
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv",ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
fout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)fout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
fout << (clock()-seed)/1000.0 <<"sec." << endl;
system("Pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <random>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
fstream fout;
fout.open("test.csv",::ios::out|ios::trunc);
int seed=clock();
mt19937_64 gen(seed);
normal_distribution<double>dis(70,10);
double a[100];
double sum=0;
for(int i=0;i<100;i++){
a[i]=(int)(round(dis(gen)));
fout<< a[i];
sum+=a[i];
if(i%10==9)fout <<endl;
fout.close();
}
system("pause");
return 0;
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv",ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
fout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)fout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
fout << (clock()-seed)/1000.0 <<"sec." << endl;
system("Pause");
return 0;
}
#include
#include
#include
#include
#include
#include
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <random>
#include <ctime>
using namespace std;
int main()
{
fstream fout;
fout.open("test.csv",ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution<double> X(70, 10);
double a[1000];
double sum = 0;
double sum2 = 0;
for (int i = 0; i < 1000; i++){
a[i] = X(gen);
fout << a[i] << "\t";
sum += a[i];
if (i % 10 == 9)fout << endl;
}
sum = sum / 1000.0;
for (int i = 0; i < 1000; i++){
sum2 += (a[i] * a[i]) - (sum * sum);
}
sum2 = sum2 / 1000;
double s = sqrt(sum2);
fout << (clock()-seed)/1000.0 <<"sec." << endl;
system("Pause");
return 0;
}
#include
#include
#include
#include
#include
#include
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
#include
#include
#include
#include
#include
#include
using namespace std;
int main(){
fstream fout;
fout.open("text.csv", ios::out | ios::trunc);
int seed = clock();
mt19937_64 gen(seed);
normal_distribution x(70, 10);
int a[100];
double sum = 0;
double s = 0;
double sum2;
for (int i = 0; i < 100; i++){
a[i] = (int)(round(x(gen)));
fout << a[i] << ",";
fout << "\n";
}
fout.close();
system("Pause");
return (0);
}
張貼留言