-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpercent_graph_multiple.cpp
156 lines (154 loc) · 3.83 KB
/
percent_graph_multiple.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <graphics.h>
#include <iomanip>
#include "drawing.h"
using namespace std;
int main() {
int total = 0;
int sum = 0;
unsigned int dian = 0, trial = 0, peach = 0;
bool chou = 0;
bool baodi_c = 0;
int baodi_w = 0;
int width = 720, height = 450; //绘图窗口长宽
bool output = false; //数值对显示状态
double percent = 0;
srand((unsigned)time(NULL));
cout.setf(ios::fixed);
initgraph(width, height, 0);
setcaption("抽中概率曲线图像");
setbkcolor(WHITE);
setcolor(RED); //默认为红色
cout << "你要抽什么? 0=角色池,1=武器池" << endl;
chou = getData<bool>(chou, 0);
cin.sync();
/*cout << "输入想中UP的次数:" << endl;
while (1) {
cin >> peach;
if (!cin) {
cout << "请输入正整数" << endl;
cin.clear();
cin.sync();
} else {
break;
}
}*/
cout << "是否显示数值对?" << endl;
output = getData<bool>(output, 0);
cin.sync();
if (chou == 0) {
for (peach = 1; peach <= 3; peach++) {
switch (peach) {
case 1:
setcolor(RED);
cout << "当前输出:抽中1次及以上概率图像,颜色:红" << endl;
break;
case 2:
setcolor(GREEN);
cout << "当前输出:抽中2次及以上概率图像,颜色:绿" << endl;
break;
case 3:
setcolor(BLUE);
cout << "当前输出:抽中3次及以上概率图像,颜色:蓝" << endl;
break;
}
for (trial = 0; trial <= 180; trial++) {
for (long times = 0; times < 100000; times++) {
int favor = 0;
unsigned int big = dian;
unsigned int smal = dian;
bool state = baodi_c;
while (big <= dian + trial) {
smal++;
big++;
//cout<<smal<<" "<<big<<endl;
int res = character::guess(smal, state);
//cout<<res<<endl;
if (res == 2) {
state = false;
favor++;
smal = 0;
} else if (res == 1) {
state = true;
smal = 0;
} //else continue;
}
if (favor >= peach) {
sum++;
}
//cout << "抽中次数:" << favor << endl;
total = total + favor;
}
percent = sum / 1000.0;
//cout << total << endl;
if (output == true) {
cout << fixed << setprecision(3) << trial << " " << percent / 100.0 << endl;
}
circle(trial * width / 180, (height - (percent / 100.0 * height)), 3);
delay_ms(0); //立即更新绘图窗口
sum = 0;
total = 0;
}
}
} else {
for (peach = 1; peach <= 3; peach++) {
switch (peach) {
case 1:
setcolor(RED);
cout << "当前输出:抽中1次及以上概率图像,颜色:红" << endl;
break;
case 2:
setcolor(GREEN);
cout << "当前输出:抽中2次及以上概率图像,颜色:绿" << endl;
break;
case 3:
setcolor(BLUE);
cout << "当前输出:抽中3次及以上概率图像,颜色:蓝" << endl;
break;
}
for (trial = 0; trial <= 240; trial++) {
for (long times = 0; times < 100000; times++) {
int favor = 0;
unsigned int big = dian;
unsigned int smal = dian;
int state = baodi_w;
while (big <= dian + trial) {
smal++;
big++;
//cout<<smal<<" "<<big<<endl;
int res = weapon::guess(smal, state);
//cout<<res<<endl;
if (res == 2) {
state = 0;
favor++;
smal = 0;
} else if (res == 1) {
state++;
smal = 0;
} //else continue;
}
if (favor >= peach) {
sum++;
}
//cout << "抽中次数:" << favor << endl;
total = total + favor;
}
percent = sum / 1000.0;
//cout << total << endl;
if (output == true) {
cout << fixed << setprecision(3) << trial << " " << percent / 100.0 << endl;
}
circle(trial * width /240, (height - (percent / 100.0 * height)), 3);
delay_ms(0); //立即更新绘图窗口
sum = 0;
total = 0;
}
}
}
cin.sync();
cin.get();
cin.get();
return 0;
}