-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.cpp
35 lines (28 loc) · 807 Bytes
/
main.cpp
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
32
33
34
35
#include "pch.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include <string>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
if (argc < 5) {
printf("Usage : %s chars n minsize maxsize", argv[0]);
return 0;
}
setlocale(LC_ALL, "");
srandom(time(NULL));
const char *chars = argv[1];
int charslen = strlen(chars);
int n = atoi(argv[2]);
int minsize = atoi(argv[3]), maxsize = atoi(argv[4]);
maxsize = max(maxsize, minsize);
string str(maxsize + 1, 0);
while (--n >= 0) {
int size = random() % (maxsize - minsize + 1) + minsize;
for (int i = 0; i < size; ++i) str[i] = chars[random() % charslen];
str[size] = 0;
cout << str.c_str() << '\n';
}
}