๐Ÿ•ธ Algorithm/๐Ÿ•ธ ๋ฐฑ์ค€ BaekJoon

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

๋‰ด์ด NUEY 2024. 1. 28. 18:43
๋ฐ˜์‘ํ˜•

import java.util.Scanner;

// 11718	๊ทธ๋Œ€๋กœ ์ถœ๋ ฅํ•˜๊ธฐ
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int cnt = 0;
		
		while(cnt < 100 && in.hasNextLine()) {
			cnt++;
			
			System.out.println(in.nextLine());
		}
	}
}
  • while๋ฌธ ์กฐ๊ฑด์œผ๋กœ Scanner์˜ hasNextLine() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•ด ์ž…๋ ฅ๊ฐ’์ด ์žˆ์„ ๋•Œ๊นŒ์ง€ ๊ตฌํ•˜๋Š”๋ฐ
  • int cnt๋กœ 100๋ฒˆ๊นŒ์ง€๋งŒ ์ž…๋ ฅ๋˜๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
๋ฐ˜์‘ํ˜•