코드비교

Old VersionNew Version
1import java.util.Scanner; 1import java.util.*;
2public class Main { 2public class Main { 
3public static void main(String[] args) { 3public static void main(String[] args) { 
4Scanner input = new Scanner(System.in); 4Scanner scanner = new Scanner(System.in);
5int num = input.nextInt(); 5int N = scanner.nextInt();
6int result =0; 6int sum=0;
7while (num > 0) { 7sum += (N%10) + (N/10%10) + (N/100);
8result += num % 10; 8if (N==1000) {sum=1;}
9num = num / 10; 9System.out.println(sum);
10}   
11System.out.println(result);   
12} 10} 
13} 11} 
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int num = input.nextInt();
int result =0;
while (num > 0) {
result += num % 10;
num = num / 10;
}
System.out.println(result);
}
}
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int sum=0;
sum += (N%10) + (N/10%10) + (N/100);
if (N==1000) {sum=1;}
System.out.println(sum);
}
}