-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcricket.c
More file actions
28 lines (27 loc) · 899 Bytes
/
cricket.c
File metadata and controls
28 lines (27 loc) · 899 Bytes
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
#include <stdio.h>
int main()
{
int balltot, runtot, runsecured, ballsdone;
scanf("%d%d%d%d", &balltot, &runtot, &runsecured, &ballsdone);
int totalOvers = balltot / 6;
int remainingBalls = balltot % 6;
float oversFinished = (ballsdone / 6) + (float)(ballsdone % 6) / 10.0;
float currentRunRate = runsecured / oversFinished;
float totalRunRate = runtot / (totalOvers + (float)remainingBalls / 10.0);
if (currentRunRate > totalRunRate)
{
printf("%d\n", totalOvers);
printf("%.1f\n", oversFinished);
printf("%.1f\n", currentRunRate);
printf("%.1f\n", totalRunRate);
printf("Eligible to Win\n");
}
else
{
printf("%d\n", totalOvers);
printf("%.1f\n", oversFinished);
printf("%.1f\n", currentRunRate);
printf("%.1f\n", totalRunRate);
printf("Not Eligible to Win\n");
}
}