코드비교

Old VersionNew Version
1import java.util.*; 1import java.util.Scanner;
2public class Main { 2public class Main { 
3public static void main(String[] args) { 3public static void main(String args[]) {
4Scanner scan = new Scanner(System.in); 4Scanner scan = new Scanner(System.in); 
5int N = scan.nextInt(); 5int N = scan.nextInt(); 
6for(int i=0;i<N;i++) { 6for(int i=0;i<N;i++) { 
7for(int j=1; j<N-i;j++) 7for(int t=1;t<N-i;t++) {
8System.out.print("   "); 8System.out.printf("%4s","");
9for(int j=0;j<=i;j++)   
10System.out.printf("%4d",(int)Math.pow(2,j));   
11for(int j=i-1;j>=0;j--)   
12System.out.printf("%4d",(int)Math.pow(2,j));   
13if(i!=N-1)   
14System.out.print("\n");   
15} 9} 
16scan.close(); 10for(int j=0;j<=i;j++) {
   11int output= (int) Math.pow(2,j);
   12System.out.printf("%4d",output);
   13}
   14for(int k=i-1;k>=0;k--) {
   15int output = (int) Math.pow(2,k);
   16System.out.printf("%4d",output);
   17}
   18System.out.println();
17} 19} 
18} 20} 
  21} 
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
for(int i=0;i<N;i++) {
for(int j=1; j<N-i;j++)
System.out.print("    ");
for(int j=0;j<=i;j++)
System.out.printf("%4d",(int)Math.pow(2,j));
for(int j=i-1;j>=0;j--)
System.out.printf("%4d",(int)Math.pow(2,j));
if(i!=N-1)
System.out.print("\n");
}
scan.close();
}
}
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scan= new Scanner(System.in);
int N = scan.nextInt();
for(int i=0;i<N;i++) {
for(int t=1;t<N-i;t++) {
System.out.printf("%4s","");
}
for(int j=0;j<=i;j++) {
int output= (int) Math.pow(2,j);
System.out.printf("%4d",output);
}
for(int k=i-1;k>=0;k--) {
int output = (int) Math.pow(2,k);
System.out.printf("%4d",output);
}
System.out.println();
}
}
}