-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPgen11235.cpp
executable file
·43 lines (38 loc) · 967 Bytes
/
Pgen11235.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
36
37
38
39
40
41
42
#include <iostream>
#include <stdio.h> /* printf, scanf, puts, NULL */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
#include <vector>
#include <algorithm>
using namespace std;
void makeRandomLine(int n) {
int x = 0;
cout << x;
for(int i = 1; i < n; ++i) {
if(rand() % 10 < 3) {
++x;
}
cout << " " << x;
}
cout << endl;
}
int main () {
/* initialize random seed: */
srand(time(NULL));
int cases = 1;
for(int j = 0; j < cases; ++j) {
int n = rand() % 10 + 1; // between 1 and max, inclusive.
int q = 10;//rand() % 10; // between 1 and max, inclusive.
cout << n << " " << q << endl;
makeRandomLine(n);
for(int i = 0; i < q; ++i) {
int a = rand() % n + 1; // between 1 and max, inclusive.
int b = rand() % n + 1; // between 1 and max, inclusive.
if(b < a)
swap(a, b);
cout << a << " " << b << endl;
}
}
cout << 0 << endl;
return 0;
}