-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprob.c
More file actions
29 lines (28 loc) · 771 Bytes
/
Copy pathprob.c
File metadata and controls
29 lines (28 loc) · 771 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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
void init_buf() {
setvbuf(stdin, 0, 2, 0);
setvbuf(stdout, 0, 2, 0);
setvbuf(stderr, 0, 2, 0);
}
int main() {
init_buf();
srand(time(0));
for(int i = 0; i < 100; i++) {
int u, v;
int x = rand() & 0xffff;
int y = rand() & 0xffff;
int ans = x + y;
printf("[*] ROUND %d\n%d + %d = ?\n", i+1, x, y);
printf("> ");
scanf("%d", &u);
if(u == ans) {
printf("right!\n");
} else {
printf("wrong\n");
exit(1);
}
}
}