#4936: JAVA RE


Kaitang (凱)


//a015: 矩陣的翻轉
import java.util.Scanner;

public class a015 {
 public static void main(String[] args) {
  Scanner sin = new Scanner(System.in);
  int a,b;
  a = sin.nextInt();
  b = sin.nextInt();
  int number[][] = new int[a][b];
  for(int row =0;row<a;row++){
   for(int commun=0;commun<b;commun++){
    number[row][commun] = sin.nextInt();
   }
  }
  for(int commun=0;commun<b;commun++){
   for(int row=0;row<a;row++){
    System.out.print(number[row][commun]+ " ");
   }
   System.out.println();
  }
 }
}

RE了...不知道哪邊有寫錯的地方

#8155: Re:JAVA RE


tripleH (tripleH)


//a015: 矩陣的翻轉
import java.util.Scanner;

public class a015 {
 public static void main(String[] args) {
  Scanner sin = new Scanner(System.in);
  int a,b;
  a = sin.nextInt();
  b = sin.nextInt();
  int number[][] = new int[a][b];
  for(int row =0;row   for(int commun=0;commun    number[row][commun] = sin.nextInt();
   }
  }
  for(int commun=0;commun   for(int row=0;row    System.out.print(number[row][commun]+ " ");
   }
   System.out.println();
  }
 }
}

RE了...不知道哪邊有寫錯的地方

補個迴圈試試

 public class a015 {

 public static void main(String[] args) {

  Scanner sin = new Scanner(System.in);

  while(sin.hasNext()){

  int a,b;

  a = sin.nextInt();

  b = sin.nextInt();

  int number[][] = new int[a][b];

  for(int row =0;row<a;row++){

   for(int commun=0;commun<b;commun++){

    number[row][commun] = sin.nextInt();

   }

  }

  for(int commun=0;commun<b;commun++){

   for(int row=0;row<a;row++){

    System.out.print(number[row][commun]+ " ");

   }

   System.out.println();

  }

  }

 }

}