코드비교

Old VersionNew Version
1import java.util.*; 1import java.util.*; 
  2import java.util.Scanner; 
2public class Main { 3public class Main { 
  4public static char convert(char a) { 
  5char b = Character.toLowerCase(a); 
  6switch(b) { 
  7case'a': case'b': case'c': 
  8b = '2'; 
  9break; 
  10case'd': case'e': case'f': 
  11b = '3'; 
  12break; 
  13case'g': case'h': case'i': 
  14b = '4'; 
  15break; 
  16case'j': case'k': case'l': 
  17b = '5'; 
  18break; 
  19case'm': case'n': case'o': 
  20b = '6'; 
  21break; 
  22case'p': case'q': case'r': case's': 
  23b = '7'; 
  24break; 
  25case't': case'u': case'v': 
  26b = '8'; 
  27break; 
  28case'w': case'x': case'y': case'z': 
  29b = '9'; 
  30break; 
  31} 
  32return b; 
  33} 
3public static void main(String[] args) { 34public static void main(String[] args) { 
4Scanner sc=new Scanner(System.in); 35Scanner sc=new Scanner(System.in); 
5int n=sc.nextInt(); 5int T = sc.nextInt();
6sc.nextLine(); 37sc.nextLine(); 
7StringBuffer arr[]=new StringBuffer[n]; 7String []a = new String [T];
8for(int i=0;i<n;i++) { 8for(int i = 0; i < T; i++) {
9String a=sc.nextLine(); 9a[i] = sc.nextLine();
10a=a.toLowerCase(); 10}
11arr[i]=new StringBuffer(a); 11for(int i = 0; i < T; i++) {
12for(int j=0;j<arr[i].length();j++) { 12for(int j = 0; j < a[i].length(); j++) {
13switch (arr[i].charAt(j)) { 13char b = a[i].charAt(j);
14case 'a': 14if(('a' <= b && 'z' >= b) || ('A' <= b && 'Z' >= b)) {
15case 'b': 15b = convert(b);
16case 'c': 16}
17arr[i].setCharAt(j,'2'); 17System.out.print(b);
18break; 18}
19case 'd': 19System.out.println();
20case 'e':   
21case 'f':   
22arr[i].setCharAt(j,'3');   
23break;   
24case 'g':   
25case 'h':   
26case 'i':   
27arr[i].setCharAt(j,'4');   
28break;   
29case 'j':   
30case 'k':   
31case 'l':   
32arr[i].setCharAt(j,'5');   
33break;   
34case 'm':   
35case 'n':   
36case 'o':   
37arr[i].setCharAt(j,'6');   
38break;   
39case 'p':   
40case 'q':   
41case 'r':   
42case 's':   
43arr[i].setCharAt(j,'7');   
44break;   
45case 't':   
46case 'u':   
47case 'v':   
48arr[i].setCharAt(j,'8');   
49break;   
50case 'w':   
51case 'x':   
52case 'y':   
53case 'z':   
54arr[i].setCharAt(j,'9');   
55break;   
56} 51} 
57} 52} 
58} 53} 
59for(int i=0;i<n;i++)   
60System.out.println(arr[i]);   
61}   
62}   
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
sc.nextLine();
StringBuffer arr[]=new StringBuffer[n];
for(int i=0;i<n;i++) {
String a=sc.nextLine();
a=a.toLowerCase();
arr[i]=new StringBuffer(a);
for(int j=0;j<arr[i].length();j++) {
switch (arr[i].charAt(j)) {
case 'a':
case 'b':
case 'c':
arr[i].setCharAt(j,'2');
break;
case 'd':
case 'e':
case 'f':
arr[i].setCharAt(j,'3');
break;
case 'g':
case 'h':
case 'i':
arr[i].setCharAt(j,'4');
break;
case 'j':
case 'k':
case 'l':
arr[i].setCharAt(j,'5');
break;
case 'm':
case 'n':
case 'o':
arr[i].setCharAt(j,'6');
break;
case 'p':
case 'q':
case 'r':
case 's':
arr[i].setCharAt(j,'7');
break;
case 't':
case 'u':
case 'v':
arr[i].setCharAt(j,'8');
break;
case 'w':
case 'x':
case 'y':
case 'z':
arr[i].setCharAt(j,'9');
break;
}
}
}
for(int i=0;i<n;i++)
System.out.println(arr[i]);
}
}
import java.util.*;
import java.util.Scanner;
public class Main {
public static char convert(char a) {
char b = Character.toLowerCase(a);
switch(b) {
case'a': case'b': case'c':
b = '2';
break;
case'd': case'e': case'f':
b = '3';
break;
case'g': case'h': case'i':
b = '4';
break;
case'j': case'k': case'l':
b = '5';
break;
case'm': case'n': case'o':
b = '6';
break;
case'p': case'q': case'r': case's':
b = '7';
break;
case't': case'u': case'v':
b = '8';
break;
case'w': case'x': case'y': case'z':
b = '9';
break;
}
return b;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
sc.nextLine();
String []a = new String [T];
for(int i = 0; i < T; i++) {
a[i] = sc.nextLine();
}
for(int i = 0; i < T; i++) {
for(int j = 0; j < a[i].length(); j++) {
char b = a[i].charAt(j);
if(('a' <= b && 'z' >= b) || ('A' <= b && 'Z' >= b)) {
b = convert(b);
}
System.out.print(b);
}
System.out.println();
}
}
}