我用範例檔測試過了很多組,答案都正確,但卻一直顯示說我錯誤?
這裡是我Java的程式碼
import java.util.*;
public class JAVA {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N;
boolean loop;
while(sc.hasNext()){
loop = true;
N = sc.nextInt();
int[] cn = new int[N];
for(int i = 0; i < N; i++){
cn[i] = 1;
}
while(loop){
N--;
for(int i = 0; i < N; i++){
cn[N - i - 1] = cn[N - i] + cn[N - i -1];
}
if(N == 1){
loop = false;
}
}
System.out.println(cn[0]);
}
}
}
我用範例檔測試過了很多組,答案都正確,但卻一直顯示說我錯誤?
這裡是我Java的程式碼
import java.util.*;
public class JAVA {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N;
boolean loop;
while(sc.hasNext()){
loop = true;
N = sc.nextInt();
int[] cn = new int[N];
for(int i = 0; i < N; i++){
cn[i] = 1;
}
while(loop){
N--;
for(int i = 0; i < N; i++){
cn[N - i - 1] = cn[N - i] + cn[N - i -1];
}
if(N == 1){
loop = false;
}
}
System.out.println(cn[0]);
}
}
}