코딩테스트/프로그래머스
[프로그래머스] ox퀴즈
애플쩀
2022. 12. 29. 10:59
package lv0;
public class OX퀴즈 {
public static int cal;
public static String[] solution(String[] quiz) {
String[] answer = new String[quiz.length];
for (int i = 0; i < quiz.length; i++) {
String[] sp=quiz[i].split(" ");
int x=Integer.parseInt(sp[0]);
int y=Integer.parseInt(sp[2]);
int z=Integer.parseInt(sp[4]);
if(sp[1].equals("-")) {
cal=x-y;
}else {
cal=x+y;
}
answer[i]= z==cal? "O":"X";
System.out.println(answer[i]);
}//for
return answer;
}
public static void main(String[] args) {
String[] quiz= {"3 - 4 = -3", "5 + 6 = 11"};
solution(quiz);
}
}