forked from nanshan-high-school/20230330-homework-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main (1).cpp
102 lines (95 loc) · 1.72 KB
/
main (1).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
#include <iostream>
using namespace std;
#include <cstdlib>
#include <ctime>
#include <stdlib.h>
void getnum(){
}
int main() {
int num[25]={26};
int duplicate=0;
int n=0,c=1,ij=0,j=0;
int bingo[5][5]={0};
srand(time(NULL));
for(int i=0;i<25;i++){
duplicate=0;
while (duplicate ==0){
c=1;
n=rand()%(25-1+1)+1;
for(int j=0;j<25;j++){
if(num[j]==n){
c=0;
break;
}
}
if (c==0)
duplicate=0;
else{
duplicate=1;
num[i]=n;
ij=i/5;
j=i%5;
bingo[j][ij]=n;
break;
}
}
}
int finish=0,line=0;
while(finish==0){
n=rand()%(25-1+1)+1;
bingo[n/5][n%5]=0;
cout<<"("<<n/5<<","<<n%5<<")"<<'\n';
for(int i=0;i<5;i++){
if(bingo[0][i]==0){
line=0;
for(int j=0;j<5;j++){
if(bingo[i][j]==0){
line++;
}
}
if (line==5){
cout<<"bingo!";
return(0);
}
}
}
for(int i=0;i<5;i++){
if(bingo[i][0]==0){
line=0;
for(int j=0;j<5;j++){
if(bingo[j][i]==0){
line++;
}
}
if (line==5){
cout<<"bingo!";
return(0);
}
}
}
if(bingo[0][0]==0){
line=0;
for(int j=0;j<5;j++){
if(bingo[j][j]==0){
line++;
}
}
if (line==5){
cout<<"bingo!";
return(0);
}
}
if(bingo[4][0]==0){
line=0;
for(int j=0;j<5;j++){
if(bingo[4-j][j]==0){
line++;
}
}
if (line==5){
cout<<"bingo!";
return(0);
}
}
}
}