๋ฐ์ํ
https://www.acmicpc.net/problem/5218
์ฝ๋
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++) {
String str1 = scan.next();
String str2 = scan.next();
int[] arr = new int[str1.length()];
for(int j=0; j<str1.length(); j++) {
if(str2.charAt(j) >= str1.charAt(j)) {
arr[j] = str2.charAt(j) - str1.charAt(j);
}
else {
arr[j] = str2.charAt(j) - str1.charAt(j) + 26;
}
}
System.out.print("Distances: ");
for(int j=0; j<arr.length; j++) {
System.out.print(arr[j] + " ");
}
System.out.println();
}
scan.close();
}
}
๋ฌธ์ ์ ๋ง๊ฒ ๊ตฌํํ๊ณ , ์ถ๋ ฅํด์ฃผ๋ฉด ๋ ..
๋ฐ์ํ
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค] 11724๋ฒ: ์ฐ๊ฒฐ ์์์ ๊ฐ์(dfs, bfs) (0) | 2020.02.06 |
---|---|
[๋ฐฑ์ค] 2262๋ฒ: ํ ๋๋จผํธ ๋ง๋ค๊ธฐ(๊ทธ๋ฆฌ๋) (0) | 2020.02.06 |
[๋ฐฑ์ค] 11403๋ฒ: ๊ฒฝ๋ก ์ฐพ๊ธฐ(dfs, bfs) (0) | 2020.02.05 |
[๋ฐฑ์ค] 1475๋ฒ: ๋ฐฉ ๋ฒํธ(๋ฌธ์์ด, ๊ตฌํ) (0) | 2020.02.05 |
ํ๋ก๊ทธ๋๋จธ์ค[Java] - ๊ตฌ๋ช ๋ณดํธ(๊ทธ๋ฆฌ๋) (0) | 2020.02.04 |
๋๊ธ