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

[๋ฐฑ์ค€] 11718๋ฒˆ: ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜๊ธฐ

by ์ฃผ๋ฐœ2 2020. 5. 1.
๋ฐ˜์‘ํ˜•

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

 

11718๋ฒˆ: ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜๊ธฐ

์ž…๋ ฅ์ด ์ฃผ์–ด์ง„๋‹ค. ์ž…๋ ฅ์€ ์ตœ๋Œ€ 100์ค„๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๊ณ , ์•ŒํŒŒ๋ฒณ ์†Œ๋ฌธ์ž, ๋Œ€๋ฌธ์ž, ๊ณต๋ฐฑ, ์ˆซ์ž๋กœ๋งŒ ์ด๋ฃจ์–ด์ ธ ์žˆ๋‹ค. ๊ฐ ์ค„์€ 100๊ธ€์ž๋ฅผ ๋„˜์ง€ ์•Š์œผ๋ฉฐ, ๋นˆ ์ค„์€ ์ฃผ์–ด์ง€์ง€ ์•Š๋Š”๋‹ค. ๋˜, ๊ฐ ์ค„์€ ๊ณต๋ฐฑ์œผ๋กœ ์‹œ์ž‘ํ•˜์ง€ ์•Š๊ณ , ๊ณต๋ฐฑ์œผ๋กœ ๋๋‚˜์ง€ ์•Š๋Š”๋‹ค.

www.acmicpc.net

์ฝ”๋“œ

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while(scan.hasNextLine()) {
			String str = scan.nextLine();
			if(str.isEmpty() || str.length() > 1000)
				break;
			System.out.println(str);
		}
		
		scan.close();
	}

}

ํ’€์ด

๋”ฐ๋กœ ์ž…๋ ฅ ์กฐ๊ฑด์€ ์—†๊ณ , ์ž…๋ ฅ์ด ์ฃผ์–ด์ง€๋Š”๋™์•ˆ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•ด์•ผํ•œ๋‹ค.

Scanner ํด๋ž˜์Šค์˜ hasNextLine() ๋ฉ”์„œ๋“œ์™€ ๋น„์–ด์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋ฉ”์„œ๋“œ isEmpty() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€