코드비교

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 sc=new Scanner(System.in); 4Scanner input=new Scanner(System.in);
5int n =sc.nextInt(); 5int n =input.nextInt();
6for(int i=0;i<n;i++) { 6for(int i=1;i<=n;i++) {
7for(int j=0;j<n-i-1;j++) { 7for(int j=0;j<n-i;j++) {
8System.out.printf("   "); 8System.out.print("   ");
9} 9} 
10for(int k=0;k<i+1;k++) { 10for (int k = 1; k <= i ;k++)
11System.out.printf("%4d",(int)Math.pow(2,k)); 11System.out.printf("%4.0f",Math.pow(2,(k - 1)));
12} 12for (int q = i;q > 1;q--)
13for(int m=0;m<i;m++) { 13System.out.printf("%4.0f",Math.pow(2,(q - 2)));
14System.out.printf("%4d",(int)Math.pow(2,i-1-m)); 14System.out.print("\n");
15}   
16System.out.println();   
17} 15} 
18} 16} 
19} 17} 
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n =sc.nextInt();
for(int i=0;i<n;i++) {
for(int j=0;j<n-i-1;j++) {
System.out.printf("    ");
}
for(int k=0;k<i+1;k++) {
System.out.printf("%4d",(int)Math.pow(2,k));
}
for(int m=0;m<i;m++) {
System.out.printf("%4d",(int)Math.pow(2,i-1-m));
}
System.out.println();
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int n =input.nextInt();
for(int i=1;i<=n;i++) {
for(int j=0;j<n-i;j++) {
System.out.print("    ");
}
for (int k = 1; k <= i ;k++)
System.out.printf("%4.0f",Math.pow(2,(k - 1)));
for (int q = i;q > 1;q--)
System.out.printf("%4.0f",Math.pow(2,(q - 2)));
System.out.print("\n");
}
}
}