- Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathrandom.cpp
More file actions
Latest commit
31 lines (27 loc) · 595 Bytes
/
Copy pathrandom.cpp
File metadata and controls
31 lines (27 loc) · 595 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<ctime>
#include<iostream>
usingnamespacestd;
intrandom(int n) {
return (longlong)rand() * rand() % n;
}
string getRandStr(int len = 5) {
string s;
for (int i = 0; i < len; i++) {
s += char('0' + random(10));
}
return s;
}
intmain() {
// 必须用随机种子,不然每次生成的数据都是一样的
srand((unsigned)time(0));
int n = 5, q = 5;
// cout << 1 << endl;
cout << n << endl;
for (int i = 1; i <= n; i++) {
{
cout << getRandStr(5);
cout << endl;
}
}
return0;
}