후ㅠㅠㅠ질문이용

stajw Reply 8 years 34 weeks ago
만약에 도시 이름이 Sa b랑 Saa라고 하면 누가 먼저 나와야하나요?? Sa b Saa 순서로 나와야하나요??
stajw Reply 8 years 34 weeks ago
import java.io.*; public class Main { public static void main(String[] args) throws IOException { String first, second, third; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); first = br.readLine(); second = br.readLine(); third = br.readLine(); int det = 0; int k = 0; for (int i = 0; i < 100; i++) { if (first.charAt(i) > second.charAt(i)) { det = 12; break; } else if (first.charAt(i) < second.charAt(i)) { det = 21; break; } } al: if (true) { if (det == 12) { for (int i = 0; i < 100; i++) { if (first.charAt(i) > third.charAt(i)) { for (int j = 0; j < 100; j++) { if (second.charAt(j) > third.charAt(j)) { System.out.println(third + " " + second + " " + first); k = 1; break al; } else if (second.charAt(j) < third.charAt(j)) { System.out.println(second + " " + third + " " + first); k = 1; break al; } } } else if (first.charAt(i) < third.charAt(i)) { if (k == 1) break; else { System.out.println(second + " " + first + " " + third); break al; } } } } else if (det == 21) { for (int i = 0; i < 100; i++) { if (second.charAt(i) > third.charAt(i)) { for (int j = 0; j < 100; j++) { if (first.charAt(j) > third.charAt(j)) { System.out.println(third + " " + first + " " + second); k = 1; break al; } else if (second.charAt(j) < third.charAt(j)) { System.out.println(first + " " + third + " " + second); k = 1; break al; } } } else if (second.charAt(i) < third.charAt(i)) { if (k == 1) break; else { System.out.println(first + " " + second + " " + third); break al; } } } } } } } 어떻게 풀긴 풀었는데 이 코드는 왜 WA가 나오는지 알 수 있을까요???ㅠㅠ
pichulia Reply 8 years 34 weeks ago
det == 21 일 때 for(j=0; ㅓ<100~~~ 이 부분에서 } else if (second.charAt(j) < third.charAt(j)) { 가 아니라 } else if (first.charAt(j) < third.charAt(j)) { 아닐까요?