Skip to content

Commit 3e4a0de

Browse files
author
DAyamaCTF
authored
Merge pull request #27 from tossy310/tossy/gpajanken
Add java solution to GPA Janken
2 parents 46febe0 + 729b4df commit 3e4a0de

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

gpajanken/cpp-kumachan/SOLUTION

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
## Solution
4+
#c_solution(src='main.c') # -lm -O2 as default
5+
cxx_solution(src='main.cpp', flags=[]) # -std=c++11 -O2 as default
6+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=[])
7+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=['10_corner*.in'])
8+
#script_solution(src='main.sh') # shebang line is required
9+
#script_solution(src='main.pl') # shebang line is required
10+
#script_solution(src='main.py') # shebang line is required
11+
#script_solution(src='main.rb') # shebang line is required
12+
#js_solution(src='main.js') # javascript (nodejs)
13+
#hs_solution(src='main.hs') # haskell (stack + ghc)
14+
#cs_solution(src='main.cs') # C# (mono)
15+
16+
## Score
17+
#expected_score(100)

gpajanken/cpp-kumachan/main.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
#include <string>
3+
4+
using namespace std;
5+
6+
void GLprint(int A, int B, string greater, string equal, string less){
7+
if(A > B){
8+
cout << greater << endl;
9+
}else if(A == B){
10+
cout << equal << endl;
11+
}else{
12+
cout << less << endl;
13+
}
14+
}
15+
16+
int main(){
17+
int T;
18+
cin >> T;
19+
20+
int A, B;
21+
for(int t = 0; t < T; ++t){
22+
cin >> A >> B;
23+
GLprint(A, B, "KATO", "DRAW", "SATO");
24+
}
25+
26+
return 0;
27+
}

gpajanken/java-tossy/GPAJanken.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Scanner;
2+
3+
public class GPAJanken {
4+
static final String win_a = "KATO";
5+
static final String win_b = "SATO";
6+
static final String draw = "DRAW";
7+
8+
public static void main(final String[] args) {
9+
final Scanner sc = new Scanner(System.in);
10+
final int n = sc.nextInt();
11+
12+
for(int i=0; i<n; i++) {
13+
final int a = sc.nextInt();
14+
final int b = sc.nextInt();
15+
16+
final String ans;
17+
if (a > b) ans = win_a;
18+
else if (a < b) ans = win_b;
19+
else ans = draw;
20+
21+
System.out.println(ans);
22+
}
23+
sc.close();
24+
}
25+
}

gpajanken/java-tossy/SOLUTION

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8; mode: python -*-
2+
3+
## Solution
4+
#c_solution(src='main.c') # -lm -O2 as default
5+
#cxx_solution(src='main.cc', flags=[]) # -std=c++11 -O2 as default
6+
java_solution(src='GPAJanken.java', encoding='UTF-8', mainclass='GPAJanken')
7+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=[])
8+
#java_solution(src='Main.java', encoding='UTF-8', mainclass='Main', challenge_cases=['10_corner*.in'])
9+
#script_solution(src='main.sh') # shebang line is required
10+
#script_solution(src='main.pl') # shebang line is required
11+
#script_solution(src='main.py') # shebang line is required
12+
#script_solution(src='main.rb') # shebang line is required
13+
#js_solution(src='main.js') # javascript (nodejs)
14+
#hs_solution(src='main.hs') # haskell (stack + ghc)
15+
#cs_solution(src='main.cs') # C# (mono)
16+
17+
## Score
18+
#expected_score(100)

0 commit comments

Comments
 (0)