Skip to content

Instantly share code, notes, and snippets.

@6LYTH3
Created July 16, 2011 03:23
Show Gist options
  • Save 6LYTH3/1085965 to your computer and use it in GitHub Desktop.
Save 6LYTH3/1085965 to your computer and use it in GitHub Desktop.
ACM_Problem E
package main;
import java.io.File;
import java.util.Scanner;
public class Relation {
public static void main(String[] args) throws Throwable {
File file = new File("txt");
Scanner sc = new Scanner(file);
String Op[] = new String[] { ">", ">=", "<", "<=", "==", "!="};
int count = 1;
while (true) {
int num1 = sc.nextInt();
String OpInput = sc.next();
int num2 = sc.nextInt();
if(OpInput.equals("E")) break;
for (int i = 0; i < 6; i++) {
if (OpInput.equals(Op[i])) {
System.out.print("case " + count++ + ": ");
switch (i) {
case 0:System.out.println(num1 > num2);
break;
case 1: System.out.println(num1 >= num2);
break;
case 2:System.out.println(num1 < num2);
break;
case 3: System.out.println(num1 <= num2);
break;
case 4:System.out.println(num1 == num2);
break;
case 5:System.out.println(num1 != num2);
break;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment