-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path다른반중간5번.cpp
69 lines (66 loc) · 1.08 KB
/
다른반중간5번.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 덧셈 공부
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int jari(int k) {
if (k < 70) {
k = 1;
}
else{
k = 2;
}
return k;
}
int random(int k) {
if (k == 1) {
return rand() % 9 + 1;
}
else if (k == 2) {
return 10 + rand() % 90;
}
}
void main()
{
int x, y, r, result, ans; // 필요하면 변수 추가
int round = 0, ok = 0;
int i = 1;
int k;
printf("7반 2071360 이종범\n");
// 난수 초기화
srand((unsigned)time(NULL));
// 무한 반복
while (1) {
k = jari(rand() % 100);
if (k == 2) {
x = random(k);
y = random(k-1);
}
else {
x = random(k);
y = random(k);
}
printf("(문제 %d) %d * %d = ", i, x, y);
scanf("%d", &result);
if (result == 0) {
printf("정답률 %2d%% (%d/%d)", ok*100 / round, ok, round);
break;
}
if (result == x * y) {
printf("정답입니다!\n");
round++;
ok++;
}
else {
printf("오답입니다!\n");
round++;
}
i++;
}
// x+y 를 확률에 따라 1자리, 2자리, 3자리 문제를 출력한다.
// ans 입력
// ans 가 0이면 반복 종료
// 정답과 오답 결과 출력
// 반복끝
// 정답률 출력
}