๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm

[๋ฐฑ์ค€] 11945๋ฒˆ: ๋œจ๊ฑฐ์šด ๋ถ•์–ด๋นต

by ์ฃผ๋ฐœ2 2020. 3. 13.
๋ฐ˜์‘ํ˜•

https://www.acmicpc.net/problem/11945

 

11945๋ฒˆ: ๋œจ๊ฑฐ์šด ๋ถ•์–ด๋นต

์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง€๋Š” ๊ฐ ํ–‰์„ ๋ฐ˜์ „์‹œ์ผœ์„œ ์ถœ๋ ฅํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ž…๋ ฅ์˜ 1ํ–‰ 1์—ด์€ ์ถœ๋ ฅ์˜ 1ํ–‰ M์—ด๋กœ, ์ž…๋ ฅ์˜ 1ํ–‰ 2์—ด์€ ์ถœ๋ ฅ์˜ 1ํ–‰ M-1์—ด๋กœ … ์ž…๋ ฅ์˜ 1ํ–‰ M์—ด์€ ์ถœ๋ ฅ์˜ 1ํ–‰ 1์—ด๋กœ … ์ž…๋ ฅ์˜ Nํ–‰ M์—ด์€ ์ถœ๋ ฅ์˜ Nํ–‰ 1์—ด๋กœ ์ถœ๋ ฅํ•˜์„ธ์š”.

www.acmicpc.net

์ฝ”๋“œ

import java.io.*; 

public class Main { 
	public static void main (String args[]) throws IOException { 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); 
		String str1[] = br.readLine().split(" "); 
		int N = Integer.parseInt(str1[0]); 
		int M = Integer.parseInt(str1[1]); 
		for (int i = 0; i < N; i++)  { 
			String str = br.readLine(); 
			for (int j = 0; j < M; j++) { 
				bw.write(str.charAt(M - j - 1)); 
			} 
			bw.write("\n"); 
		} 
		bw.flush(); 
	} 
}

ํ’€์ด

๋ฌธ์ œ ๊ทธ๋Œ€๋กœ ๋’ค์ง‘์–ด์„œ ์ถœ๋ ฅํ•˜๋ฉด ๋˜๋Š”๋ฐ,,

bw.write(str.charAt(M - j - 1)); 

์ด์ƒํ•˜๊ฒŒ StringBuilder๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ถœ๋ ฅํ•˜๋ฉด ๋Ÿฐํƒ€์ž„์ด ๋ฐœ์ƒํ•œ๋‹ค.

๊ทธ๋ž˜์„œ Buffered๋ฅผ ํ†ตํ•ด ์ถœ๋ ฅ์„ ํ–ˆ๋”๋‹ˆ ์ œ์ถœ๋๋‹ค .

 

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€