-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCricketPlayerAnalysis.c
246 lines (173 loc) · 7.26 KB
/
CricketPlayerAnalysis.c
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
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
struct batsman
{
char name[25];
int runs,score,balls,toruns,tobal,ones,twos,threes,fours,sixes;
int max_six,max_run,max_four;
float str;
}pl1[100],pl3;
struct bowler
{
char name[25];
int runsgv,wkttkn,overs;
int max_w;
float econ;
}pl2[100],pl4;
int main()
{
system("color 3F");
int plno,choice;
int i,n,m,k;
printf("====================Enter the Batsman detail===============\n");
while(1){
printf("\nEnter the number of Players in a Team:\n");
scanf("%d",&k);
if(k<12){
while(2){
printf("\nEnter the number of Batsman:\n");
scanf("%d",&m);
if(m<7){
for(i=0;i<m;i++)
{
printf("Enter name of batsman%d:\n",i+1);
scanf("%s",pl1[i].name);
printf("Enter the number of ones scored by player%d:\n ",i+1);
scanf("%d",&pl1[i].ones);
printf("Enter the number of twos scored by player%d:\n ",i+1);
scanf("%d",&pl1[i].twos);
printf("Enter the number of threes scored by player%d:\n ",i+1);
scanf("%d",&pl1[i].threes);
printf("Enter the number of fours scored by player%d:\n ",i+1);
scanf("%d",&pl1[i].fours);
printf("Enter the number of sixes scored by player%d:\n ",i+1);
scanf("%d",&pl1[i].sixes);
printf("Enter the balls played by the player%d:\n",i+1);
scanf("%d",&pl1[i].balls);
}
printf("\n==============================Enter the bowlers details===========================\n");
while(3){
printf("\nEnter the number of bowlers:\n");
scanf("%d",&n);
if(n<6){
for(i=0;i<n;i++)
{
printf("\nEnter name of bowler%d:\n",i+1);
scanf("%s",pl2[i].name);
printf("Enter the runs given by the bowler%d:\n ",i+1);
scanf("%d",&pl2[i].runsgv);
printf("Enter the overs bowled by the bowler%d:\n",i+1);
scanf("%d",&pl2[i].overs);
printf("Enter the wickets taken by the bowler%d\n",i+1);
scanf("%d",&pl2[i].wkttkn);
}
printf("==========================Thank you all details are recorded===================\n");
do
{
printf("Enter the choice:\n 1)Batsman detail:\n 2)Bowlers detail:\n 3)Match summary:\n 4)Record:\n 5)Exit\n ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the batsman number to see his details\n");
scanf("%d",&plno);
plno--;
printf(" Player Detail\n");
printf("===========================================================================\n");
printf(" Batsman runs balls fours sixes sr \n");
printf("===========================================================================\n");
pl1[plno].runs=(1*pl1[plno].ones)+(2*pl1[plno].twos)+(3*pl1[plno].threes)+(4*pl1[plno].fours)+(6*pl1[plno].sixes);
pl1[plno].str=(pl1[plno].runs*100.00)/pl1[plno].balls;
printf(" %-15s %-14d %-13d %-11d %-11d %-9.2f\n\n",pl1[plno].name,pl1[plno].runs,pl1[plno].balls,pl1[plno].fours,pl1[plno].sixes,pl1[plno].str);
break;
case 2:
printf("Enter the bowlers number to see his details\n");
scanf("%d",&plno);
plno--;
printf(" Player Detail\n ");
printf("=================================================================\n");
printf(" Bowler overs runs wicket economy\n");
printf("=================================================================\n");
for(i=0;i<n;i++)
{ pl2[plno].econ=pl2[plno].runsgv/pl2[plno].overs;
printf(" %-15s %-14d %-13d %-11d %-11.2f\n\n",pl2[plno].name,pl2[plno].overs,pl2[plno].runsgv,pl2[plno].wkttkn,pl2[plno].econ);
}
break;
case 3:
printf(" Match summary\n");
printf("==========================================================================\n");
printf(" Batsman runs balls fours sixes sr \n");
printf("==========================================================================\n");
for(i=0;i<1;i++)
{
pl1[i].runs=(1*pl1[i].ones)+(2*pl1[i].twos)+(3*pl1[i].threes)+(4*pl1[i].fours)+(6*pl1[i].sixes);
pl3.toruns+=pl1[i].runs;
pl1[i].str=(pl1[i].runs*100.00)/pl1[i].balls;
printf(" %-15s %-14d %-13d %-11d %-11d %-9.2f\n\n",pl1[i].name,pl1[i].runs,pl1[i].balls,pl1[i].fours,pl1[i].sixes,pl1[i].str);
}
printf("TOTAL RUNS:%d\n\n",pl3.toruns);
printf("\n\n");
printf("=================================================================\n");
printf(" Bowler overs runs wicket economy\n");
printf("=================================================================\n");
for(i=0;i<n;i++)
{ pl2[i].econ=pl2[i].runsgv/pl2[i].overs;
printf(" %-15s %-14d %-13d %-11d %-11.2f\n\n\n",pl2[i].name,pl2[i].overs,pl2[i].runsgv,pl2[i].wkttkn,pl2[i].econ);
}
break;
case 4: pl3.max_run=0,pl4.max_w=0,pl3.max_four=0,pl3.max_six=0;
for(i=0;i<m;i++)
{
pl1[i].runs=(1*pl1[i].ones)+(2*pl1[i].twos)+(3*pl1[i].threes)+(4*pl1[i].fours)+(6*pl1[i].sixes);
if(pl3.max_run<pl1[i].runs)
{
pl3.max_run=pl1[i].runs;
}
if(pl3.max_six<pl1[i].sixes)
{
pl3.max_six=pl1[i].sixes;
}
if(pl3.max_four<pl1[i].fours)
{
pl3.max_four=pl1[i].fours;
}
if(pl4.max_w<pl2[i].wkttkn)
{
pl4.max_w=pl2[i].wkttkn;
}
}
printf("Highest runs scored by the batsman:->%d\n",pl3.max_run);
printf("Maximum fours scored by the batsman:->%d\n",pl3.max_four);
printf("Maximum sixes scored by the batsman:->%d\n",pl3.max_six);
printf("Maximum wickets taken by the bowler:->%d\n",pl4.max_w);
break;
case 5:
exit(1);
default:
printf("Enter the correct choice\n");
break;
}
}while(choice!=5);
}
else{
Beep(1000,1000);
printf("ENTER THE VALID NUMBER OF BOWLERS\n");
}
}
}
else
{
Beep(1000,1000);
printf("Enter the valid number of Batsman");
}
}
}
else
{
Beep(1000,1000);
printf("Enter the valid number of Players");
}
}
return 0;
}