01-08 08:57
Recent Posts
Recent Comments
๊ด€๋ฆฌ ๋ฉ”๋‰ด

miinsun

[Algorithm]์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ž๋ฐ”_4 ๋‹จ์–ด ๋’ค์ง‘๊ธฐ ๋ณธ๋ฌธ

Algorithm/Java

[Algorithm]์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ž๋ฐ”_4 ๋‹จ์–ด ๋’ค์ง‘๊ธฐ

miinsun 2022. 1. 2. 23:05

 

๐Ÿ’ฌ ๋ฌธ์ œ ์„ค๋ช…

N๊ฐœ์˜ ๋‹จ์–ด๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ๊ฐ ๋‹จ์–ด๋ฅผ ๋’ค์ง‘์–ด ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์„ธ์š”.

 

 

๐Ÿ”จ ์ž…์ถœ๋ ฅ ์˜ˆ

์ž…๋ ฅ - ์ฒซ ์ค„์— ์ž์—ฐ์ˆ˜ N(3<=N<=20)์ด ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. ๋‘ ๋ฒˆ์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ๋‹จ์–ด๊ฐ€ ๊ฐ ์ค„์— ํ•˜๋‚˜์”ฉ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. ๋‹จ์–ด๋Š” ์˜์–ด ์•ŒํŒŒ๋ฒณ์œผ๋กœ๋งŒ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

3
good
Time
Big

์ถœ๋ ฅ - N๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ž…๋ ฅ๋œ ์ˆœ์„œ๋Œ€๋กœ ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ๋’ค์ง‘์–ด์„œ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

doog
emiT
giB

โ€‹

๐Ÿ’ป Solution.java

import java.util.Scanner;
  
public class Main {
	public void solution(int len, String[] strArr) {
		
		for(String s : strArr) {
			String tmp = "";
			for(int i = s.length() - 1; i >= 0; i--) {
				tmp += s.charAt(i);
			}
			System.out.println(tmp);
		}
	}
	
	public static void main(String[] args){
		Main main  = new Main();
		Scanner sc =new Scanner(System.in);
		int len = sc.nextInt();
		String[] strArr = new String[len];
		
		for(int i = 0; i < len; i++) {
			strArr[i] = sc.next();
		}
		
		main.solution(len, strArr);
		sc.close();
		return ;
	}
}

 

Comments