제 코드인데 인텔리제이에서 돌아가지 않아서 아직 submit을 못했습니다 왜 돌아가지 않는

990299 Reply 8 years 32 weeks ago
import java.io.IOException; import java.util.*; import java.lang.*; import static java.lang.String.*; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); sc.nextLine(); String str[] = {null}; char[][] array = new char[T][]; char[][] temp = new char[T][]; for(int i = 0 ; i < T ; i++) { str[i] = sc.next(); array[i] = str[i].toCharArray(); for(int k = 0 ; k < array[i].length ; k++) { temp[i][k] = array[i][array[i].length - 1 - k]; } if(array[i] == temp[i]) System.out.println("Y"); else System.out.println("N"); } } } 디버깅을 해보니까 temp[i] 배열에 array[i]를 거꾸로 복사하는 과정에서 오류가 나면서 멈추더라구요... 왜인지 알고 싶습니다
pichulia Reply 8 years 32 weeks ago
temp[i] 배열에 메모리할당이 안되있네요. temp[i] = new char[arr[i].lenght()]; 를 추가하시면 안정적으로 Wrong Answer를 받으실 수 있습니다.
990299 Reply 8 years 32 weeks ago
ㅋㅋㅋ감사합니다