문자열 역순
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String str;
System.out.println("문자열 입력:");
str = input.nextLine();
char[] array = str.toCharArray();
int len = str.length();
for(int i = 0; i < len/2 ; i++)
{
char temp = array[i];
array[i] = array[len-i-1];
array[len-i-1] = temp;
}
for(int j = 0; j < len; j++)
System.out.print(array[j]);
}
댓글 없음:
댓글 쓰기