Given the following inputs:
String s; |
Write a for loop that will print out the reverse of the string.
Sample input/outputs:
In: manhattan out: nattahnam
In: processor out: rossecorp
In: racecar out: racecar |
Solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Bakjoon {
public static void main(String[] args) {
Scanner inp = new Scanner(System.in);
System.out.print("In:");
String s = inp.nextLine();
//write your code below
for(int i=s.length()-1;i>=0;i--) {
System.out.print(s.charAt(i));
}
}
}
|
반응형
'Java_beginner(Repl.it) > Auto-Graded-Course(AP CS A)' 카테고리의 다른 글
032 - For Loop Challenge 1 (optional) (0) | 2019.12.07 |
---|---|
031 - Further For Loop Practice 7 (mIxEd CaSe) (0) | 2019.12.07 |
029 - Further For Loop Practice 5 (printing characters) (0) | 2019.12.07 |
028 - Further For Loop Practice 4 (repeating X times) (0) | 2019.12.07 |
027 - Further For Loop Practice 3 (descending) (0) | 2019.12.07 |