-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawing.h
106 lines (104 loc) · 2.09 KB
/
drawing.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef DRAWING_H
#define DRAWING_H
#include <iostream>
using namespace std;
template <typename T> getData(T target, bool type) { //type: target的类型。0 = 布尔值(bool), 1 = unsigned int非负整型
while (1) {
cin >> target;
if (!cin) {
if (type == 0) {
cout << "请输入0或1" << endl;
} else {
std::cout << "请输入非负整数" << std::endl;
}
cin.clear();
cin.sync();
} else {
return target;
}
}
return 0;
}
namespace character {
int guess(unsigned int &s, bool &st) {
long long ra = (double)rand() / RAND_MAX * 1000;
if (s > 73) {
if (s == 90) {
if (st == true) {
return 2;
} else if (ra >= 1 && ra <= (500)) {
return 2;
} else {
return 1;
}
} else if (ra >= 1 && (ra <= (6 + (s - 73) * 60))) {
if (st == true) {
return 2;
} else if (ra >= 1 && ra <= ((6 + (s - 73) * 60) / 2)) {
return 2;
} else {
return 1;
}
} else {
return 3;
}
} else {
if (ra >= 1 && ra <= 6) {
if (st == true) {
return 2;
} else if (ra >= 1 && ra <= 3) {
return 2;
} else {
return 1;
}
} else {
return 3;
}
}
}
}
namespace weapon {
int guess(unsigned int &s, int &st) {
long double ra = (double)rand() / RAND_MAX * 1000;
if (s > 63) {
if (s == 80) {
if (st == 2) {
return 2;
} else if (ra >= 1 && ra <= 375) {
return 2;
} else if (ra > 375 && ra <= 1000) {
return 1;
}
} else if (ra >= 1 && (ra <= (7 + (s - 63) * 60))) {
if (st == 2) {
return 2;
} else if (ra >= 1 && ra <= ((7 + (s - 63) * 60) * 0.75)) {
if (ra >= 1 && ra <= ((7 + (s - 63) * 60) * 0.375)) {
return 1;
} else {
return 2;
}
return 2;
} else {
return 1;
}
} else {
return 3;
}
} else {
if (ra >= 1 && ra <= 7) {
if (st == 2) {
return 2;
} else if (ra >= 1 && ra <= 2.625) {
return 2;
} else {
return 1;
}
} else {
return 3;
}
}
return 3; //符合规范,实无意义
}
}
#endif