Skip to content

Commit a63943d

Browse files
authored
Create Cricket_Ranking.c
1 parent 86a1306 commit a63943d

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

Codechef Problems/Cricket_Ranking.c

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/* PROBLEM STATEMENT
2+
3+
In a season, each player has three statistics: runs, wickets, and catches. Given the season stats of two players A and B, denoted by R, W, and C respectively,
4+
the person who is better than the other in the most statistics is regarded as the better overall player. Tell who is better amongst A and B. It is known that in each statistic,
5+
the players have different values.
6+
7+
Input Format
8+
The first line contains an integer T, the number of test cases. Then the test cases follow.
9+
Each test case contains two lines of input.
10+
The first line contains three integers R1, W1, C1, the stats for player A.
11+
The second line contains three integers R2, W2, C2, the stats for player B.
12+
Output Format
13+
For each test case, output in a single line "A" (without quotes) if player A is better than player B and "B" (without quotes) otherwise.
14+
15+
Constraints
16+
1≤T≤1000
17+
0≤R1,R2≤500
18+
0≤W1,W2≤20
19+
0≤C1,C2≤20
20+
R1≠R2
21+
W1≠W2
22+
C1≠C2
23+
24+
Sample Input 1
25+
3
26+
0 1 2
27+
2 3 4
28+
10 10 10
29+
8 8 8
30+
10 0 10
31+
0 10 0
32+
33+
Sample Output 1
34+
B
35+
A
36+
A
37+
38+
Explanation
39+
Test Case 1: Player B is better than A in all 3 fields.
40+
41+
Test Case 2: Player A is better than B in all 3 fields.
42+
43+
Test Case 3: Player A is better than B in runs scored and number of catches. */
44+
45+
46+
#include <stdio.h>
47+
48+
int main(void) {
49+
int i=0;
50+
int tc;
51+
// tc is to take input the number of test cases
52+
scanf("%d",&tc);
53+
int a[tc];
54+
int t=tc;
55+
int r1,w1,c1,r2,w2,c2;
56+
while(tc--)
57+
{
58+
scanf("%d %d %d",&r1,&w1,&c1); //stores respective inputs for player A
59+
scanf("%d %d %d",&r2,&w2,&c2); //stores respective inputs for player B
60+
61+
if(((w1>w2)&&(r1>r2)&&(c1>c2))||((w1>w2)&&(c1>c2))||((c1>c2)&&(r1>r2))||((r1>r2)&&(w1>w2)))
62+
{
63+
a[i]=1; //stores 1 in the array for results favouring player A
64+
}
65+
else
66+
{
67+
a[i]=2; //stores 1 in the array for results favouring player B
68+
}
69+
i++;
70+
}
71+
72+
for(int j=0;j<t;j++)
73+
{
74+
if(a[j]==1)
75+
{
76+
printf("A \n");
77+
78+
}
79+
else
80+
{
81+
printf("B \n");
82+
}
83+
84+
}
85+
return 0;
86+
}

0 commit comments

Comments
 (0)