import java.util.Scanner;
public class RRR {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt() , b = sc.nextInt();
int[][] array = new int[a][b];
if(array.length < 100)
while(sc.hasNext()){
for(int row =0 ; row< a ; row++){
for(int col =0; col<b ; col++){
int value = sc.nextInt();
array[row][col] = value;
}
}
for(int c =0; c< b ; c++){
for(int d=0 ; d<a ; d++){
System.out.print(array[d][c] + " ");
}
System.out.println();
}
}
}
}
import java.util.Scanner;
public class RRR {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt() , b = sc.nextInt();
int[][] array = new int[a][b];
if(array.length < 100)
while(sc.hasNext()){
for(int row =0 ; row< a ; row++){
for(int col =0; col
int value = sc.nextInt();
array[row][col] = value;
}
}
for(int c =0; c< b ; c++){
for(int d=0 ; d System.out.print(array[d][c] + " ");
}
System.out.println();
}
}
}
}
第 1 測資點(100%): WA (line:4)
答案不正確
您的答案為: 1 5 正確答案為: 3
真的快瘋掉了 研究一天還是不知道為什麼qq
import java.util.Scanner;
public class RRR {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt() , b = sc.nextInt();
int[][] array = new int[a][b];
if(array.length < 100)
while(sc.hasNext()){
for(int row =0 ; row< a ; row++){
for(int col =0; col
int value = sc.nextInt();
array[row][col] = value;
}
}
for(int c =0; c< b ; c++){
for(int d=0 ; d System.out.print(array[d][c] + " ");
}
System.out.println();
}
}
}
}
第 1 測資點(100%): WA (line:4)
答案不正確
您的答案為: 1 5 正確答案為: 3
真的快瘋掉了 研究一天還是不知道為什麼qq
因為有多筆資料,所以你的
int a = sc.nextInt() , b = sc.nextInt();
要放while(sc.hasNext())裡面
不然你的陣列大小就等於第一筆指定的大小