工程实践:世界杯随机分组

世界杯随机分组源码

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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<Windows.h>
#include <conio.h>

void AllocateSeedTeams(char* aim[], char* a[], char* b[], char* c[], char* d[], char* e[], char* f[], char* g[], char* h[]);
void RandomGroup( char* Team[], char* Seed[], char* a[], char* b[], char* c[], char* d[], char* e[], char* f[], char* g[], char* h[] );

int main()
{
int a, b, c, d, e, f, g, h;
char choice;
char* name[] = { "英格兰","法国","德国","意大利","西班牙","荷兰","葡萄牙","克罗地亚","土耳其","俄罗斯","瑞典","捷克","塞尔维亚","加纳","科特迪瓦","突尼斯","尼日利亚","喀麦隆","日本","韩国","澳大利亚","伊朗","美国","墨西哥","哥斯达黎加","洪都拉斯","巴西","阿根廷","巴拉圭","智利","乌拉圭","厄瓜多尔" };
char* Send[] = { "乌拉圭","西班牙","德国","阿根廷","荷兰","法国","巴西","俄罗斯" };
char* SeedTeam1[] = { "" ,"" ,"" ,"" };
char* SeedTeam2[] = { "" ,"" ,"" ,"" };
char* SeedTeam3[] = { "" ,"" ,"" ,"" };
char* SeedTeam4[] = { "" ,"" ,"" ,"" };
char* SeedTeam5[] = { "" ,"" ,"" ,"" };
char* SeedTeam6[] = { "" ,"" ,"" ,"" };
char* SeedTeam7[] = { "" ,"" ,"" ,"" };
char* SeedTeam8[] = { "" ,"" ,"" ,"" };

Restart:
printf( "正在为您分组,小主请稍等片刻······" );

AllocateSeedTeams( Send, SeedTeam1, SeedTeam2, SeedTeam3, SeedTeam4, SeedTeam5, SeedTeam6, SeedTeam7, SeedTeam8 );

RandomGroup( name, Send, SeedTeam1, SeedTeam2, SeedTeam3, SeedTeam4, SeedTeam5, SeedTeam6, SeedTeam7, SeedTeam8 );

MessageBox(NULL,
(LPCWSTR)L"将为小主展示分组结果orz\n斯哈斯哈@A@",
(LPCWSTR)L"小主,您的要的分组结果出炉咯!",
MB_OK | MB_ICONINFORMATION
);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0Xa1);
printf( "\tSeed Team\n" );

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 0X0d );
for (a = 0; a < 4; a++)
{
printf( "\t%-10s",SeedTeam1[a]);
if (a == 3)
{
printf("\n");
}
}

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0c );
for (b = 0; b < 4; b++)
{
printf("\t%-10s", SeedTeam2[b]);
if (b == 3)
{
printf("\n");
}
}

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X07 );
for (c = 0; c < 4; c++)
{
printf("\t%-10s", SeedTeam3[c]);
if (c == 3)
{
printf("\n");
}
}

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0b );
for (d = 0; d < 4; d++)
{
printf("\t%-10s", SeedTeam4[d]);
if (d == 3)
{
printf("\n");
}
}

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X09 );
for (e = 0; e < 4; e++)
{
printf("\t%-10s", SeedTeam5[e]);
if (e == 3)
{
printf("\n");
}
}


SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
for (f = 0; f < 4; f++)
{SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f );
printf("\t%-10s", SeedTeam6[f]);
if (f == 3)
{
printf("\n");
}
}

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0a );
for (g = 0; g < 4; g++)
{
printf("\t%-10s", SeedTeam7[g]);
if (g == 3)
{
printf("\n");
}
}

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0e );
for (h = 0; h < 4; h++)
{
printf("\t%-10s", SeedTeam8[h]);
if (h == 3)
{
printf("\n");
}
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf("\t--------------------------------------------------------\n");

printf("\n\n");
printf( " 2022.11.21 - 2022.12.18\n" );
printf( " In Qatar\n" );
printf( " Stay tuned\n" );
printf( "\n" );
Function:
fflush(stdout);
fflush(stdin);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0X0f);
printf( "If you want to see more grouped results, please enter \"r\"\n" );
printf( "If you want to exit, enter \"e\"\n" );
printf( "If you want to watch the World Cup, enter \"w\"\n" );
printf( "If you want to know how grouping works, please enter \"y\"\n" );
printf( "\(The above input is not case sensitive\)\n");
printf( "Please type what you want: " );
choice = _getch();
if (choice == 82 || choice == 114)
{
system("CLS");
goto Restart;
}
if (choice == 69 || choice == 101)
{
printf( "Exit soon..." );
Sleep(2000);
exit(0);
}
if (choice == 87 || choice == 119)
{
printf( "Coming soon to the browser..." );
Sleep(1000);
system("start https://sports.qq.com/");
system("CLS");
goto Function;
}
if (choice == 89 || choice == 121)
{
printf( "Welcome to my blog ^^ ..." );
Sleep(1000);
system("start https://kamasammohana.github.io");
system("CLS");
goto Function;
}
else
{
printf( "Wrong input,try again ^^" );
Sleep(1500);
system("CLS");
goto Function;
}
}

void AllocateSeedTeams(char* aim[], char* a[], char* b[], char* c[], char* d[], char* e[], char* f[], char* g[], char* h[])
{
*a = aim[0];
*b = aim[1];
*c = aim[2];
*d = aim[3];
*e = aim[4];
*f = aim[5];
*g = aim[6];
*h = aim[7];
}

void RandomGroup(char* Team[], char* Seed[], char* a[], char* b[], char* c[], char* d[], char* e[], char* f[], char* g[], char* h[])
{
int i;
int random;
int element[8] = { 1, 1, 1, 1, 1, 1, 1, 1 };
for (i = 0; i < 32; i++)
{
if (strcmp(Team[i], Seed[0]) == 0 || strcmp(Team[i], Seed[1]) == 0 || strcmp(Team[i], Seed[2]) == 0 || strcmp(Team[i], Seed[3]) == 0 || strcmp(Team[i], Seed[4]) == 0 || strcmp(Team[i], Seed[5]) == 0 || strcmp(Team[i], Seed[6]) == 0 || strcmp(Team[i], Seed[7]) == 0)
{
continue;
}
RepeatGroup:
srand(time(0));
random = rand() % 8 + 1;
if (element[random - 1] == 4)
{
goto RepeatGroup;
}
if (random == 1)
{
a[element[0]] = Team[i];
element[0]++;
}
if (random == 2)
{
b[element[1]] = Team[i];
element[1]++;
}
if (random == 3)
{
c[element[2]] = Team[i];
element[2]++;
}
if (random == 4)
{
d[element[3]] = Team[i];
element[3]++;
}
if (random == 5)
{
e[element[4]] = Team[i];
element[4]++;
}
if (random == 6)
{
f[element[5]] = Team[i];
element[5]++;
}
if (random == 7)
{
g[element[6]] = Team[i];
element[6]++;
}
if (random == 8)
{
h[element[7]] = Team[i];
element[7]++;
}
}
}
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2022-2023 Syclover.Kama
  • 访问人数: | 浏览次数:

请我喝杯咖啡吧~

支付宝
微信