Skip to content

Commit 004775b

Browse files
authored
Create Chess_Format.c
1 parent 8ee6738 commit 004775b

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* PROBLEM STATEMENT
2+
3+
Given the time control of a chess match as a+b, determine which format of chess out of the given 4 it belongs to.
4+
5+
1) Bullet if a+b<3
6+
7+
2) Blitz if 3≤a+b≤10
8+
3) Rapid if 11≤a+b≤60
9+
10+
4) Classical if 60<a+b
11+
Input Format
12+
First line will contain T, number of testcases. Then the testcases follow.
13+
Each testcase contains a single line of input, two integers a,b.
14+
Output Format
15+
For each testcase, output in a single line, answer 1 for bullet, 2 for blitz, 3 for rapid, and 4 for classical format.
16+
17+
Constraints
18+
1≤T≤1100
19+
1≤a≤100
20+
0≤b≤10
21+
Sample Input 1
22+
4
23+
1 0
24+
4 1
25+
100 0
26+
20 5
27+
Sample Output 1
28+
1
29+
2
30+
4
31+
3
32+
Explanation
33+
TestCase 1: Since a+b=1<3, it belongs to bullet format.
34+
35+
TestCase 2: Since 3≤(a+b=5)≤10, it belongs to blitz format. */
36+
#include <stdio.h>
37+
38+
int main(void) {
39+
40+
int t,a,b;
41+
scanf("%d",&t); int tc=t;
42+
//t= number of test cases
43+
int arr[t];
44+
int i=0;
45+
while(t--)
46+
{
47+
scanf("%d %d",&a,&b);
48+
49+
int sum=a+b;
50+
if(sum<3)
51+
{
52+
arr[i]=1;
53+
}
54+
else if((sum>=3)&&(sum<=10))
55+
{
56+
arr[i]=2;
57+
}
58+
else if((sum>=11)&&(sum<=60))
59+
{
60+
arr[i]=3;
61+
}
62+
else
63+
{
64+
arr[i]=4;
65+
}
66+
i++;
67+
}
68+
69+
for(i=0;i<tc;i++)
70+
{
71+
printf("%d\n",arr[i]);
72+
}
73+
74+
75+
76+
77+
return 0;
78+
}

0 commit comments

Comments
 (0)