?? random.cpp
字號:
//從數組中提取一組(六個)隨機數,
//一共循環抽取5次并且將抽取的結果
//保存在一個一個RADOM.TXT文件里
//(分行保存).
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<fstream>
using namespace std;
int main()
{
ofstream outClientFile("c:\\RADOM.TXT", ios::out);
if(!outClientFile)
{
cerr<<"File can not open"<<endl;
exit(1);
}
int a[10][6]={1,2,3,4,5,6,7,8,9,0,
11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60};
srand(time(0));
for(int j=0;j<5;j++)
{
for(int i=0;i<6;i++)
outClientFile<<setw(5)<<a[rand()%10][rand()%6];
outClientFile<<endl;
}
cin.get();
return 0;
}
/*保存后的格式為:右對齊5個字符位置
因為網頁上不能顯示空格,在此我舉例說明
其中@表示空格,而非程序中顯示
@@@@5@@@43@@@33@@@44@@@45@@@39
@@@@5@@@19@@@@4@@@21@@@51@@@@9
@@@13@@@28@@@18@@@51@@@49@@@49
@@@38@@@34@@@@6@@@32@@@15@@@@4
@@@31@@@17@@@39@@@16@@@@5@@@30
*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -