반응형
문제
Day 7: Arrays | HackerRank
Getting started with Arrays.
www.hackerrank.com
문제 설명
배열로 받은 n개의 문자열을
거꾸로 출력해라
성공 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public class Solution {
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int n = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
String[] arrItems = scanner.nextLine().split(" ");
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
for (int i = n-1; i >= 0; i--) {
int arrItem = Integer.parseInt(arrItems[i]);
System.out.print(arrItem + " ");
}
scanner.close();
}
}
|
cs |
반응형