Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
62 lines (55 loc) · 1.21 KB

File metadata and controls

62 lines (55 loc) · 1.21 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*The RPS world championship is here. Here two players A and B play the game. You need to determine who wins.
Both players can choose moves from the set {R,P,S}.
The game is a draw if both players choose the same item.
The winning rules of RPS are given below:
Rock crushes scissor
Scissor cuts paper
Paper envelops rock
Input:
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains single line of input that contains two characters sidebyside. These characters denote the moves of players A and B respectively.
Output:
For each testcase, in a newline, print the winner. If match is draw, print 'DRAW'.
Constraints:
1<= T <= 50
Example:
Input:
7
RR
RS
SR
SP
PP
PS
RP
Output:
DRAW
A
B
A
DRAW
B
B*/
import java.util.*;
class GFG {
public static void main (String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
sc.nextLine();
while(t!=0)
{
String str=sc.nextLine();
if(str.charAt(0)==str.charAt(1))
{
System.out.println("DRAW");
}
else if(str.equals("RS")||str.equals("PR")||str.equals("SP"))
{
System.out.println("A");
}
else
System.out.println("B");
t--;
}
sc.close();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.