Banner

My Tech Blog (์ž…๋ ฅ)

ํŒŒ์ด์ฌ ์ž˜ ์•ˆ ํ•ด์„œ ํ•ญ์ƒ ํ—ท๊ฐˆ๋ฆฌ๋Š” ๋ถ€๋ถ„ ์ •๋ฆฌ ํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.  1. sys.stdin.readline() sys.stdin.readline()์€ Python์—์„œ ํ‘œ์ค€ ์ž…๋ ฅ์„ ํ†ตํ•ด ํ•œ ์ค„์˜ ์ž…๋ ฅ์„ ๋ฐ›์„ ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ํ•จ์ˆ˜์ด ํ•จ์ˆ˜๋Š” ์ „์ฒด ์ค„์„ ์ž…๋ ฅ๋ฐ›์€ ํ›„, ๋งˆ์ง€๋ง‰์— ์ค„๋ฐ”๊ฟˆ ๋ฌธ์ž(\n)๋ฅผ ํฌํ•จํ•œ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ ๋ณดํ†ต input() ํ•จ์ˆ˜์™€ ๋น„์Šทํ•œ ์—ญํ• ์„ ํ•˜์ง€๋งŒ, ์„ฑ๋Šฅ์ด ๋” ๋น ๋ฅด๊ณ  ๋Œ€๋Ÿ‰์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•  ๋•Œ ๋” ํšจ์œจ์ ์ž„.ํŠนํžˆ ํŒŒ์ผ์ด๋‚˜ ํŒŒ์ดํ”„๋ผ์ธ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์„ ๋•Œ ์œ ์šฉํ•˜๋‹ค๊ณ  ์•Œ๋ ค์ ธ ์žˆ๋‹ค. 2. ์‚ฌ์šฉ๋ฒ• โœ… ๊ธฐ๋ณธ ์‚ฌ์šฉ๋ฒ•import sys // sys ๋ชจ๋“ˆ ๊ฐ€์ ธ์˜ค๊ธฐ# ํ•œ ์ค„ ์ž…๋ ฅ ๋ฐ›๊ธฐline = sys.stdin.readline()# ์ถœ๋ ฅprint("์ž…๋ ฅํ•œ ๋‚ด์šฉ:", line)  โœ… ์ž…๋ ฅ ๋ฐ›์€ ํ›„ ์ค„๋ฐ”๊ฟˆ(\n) ์ œ๊ฑฐsy..
โœ…๋ฌธ์ œA, B ์ˆซ์ž๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.A-B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.A์™€ B๊ฐ€ ๋ชจ๋‘ 0์„ ์ž…๋ ฅ ๋ฐ›์œผ๋ฉด ํ”„๋กœ๊ทธ๋žจ์ด ์ข…๋ฃŒ๋œ๋‹ค. โœ…์ฝ”๋“œimport java.util.Scanner;public class bonus01 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { System.out.print("A ์ž…๋ ฅ >> "); int num1 = sc.nextInt(); System.out.print("B ์ž…๋ ฅ >> "); int num2 = sc.nextInt(); System.out.println("๊ฒฐ๊ณผ >> " + (num1 - num2)); if (num1 == 0 && num2 == ..
โœ… ๋ฌธ์ œ  [์ž…๋ ฅ]1. N๊ณผ X๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.2. N๊ฐœ์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค. (๋ฐ˜๋ณต๋ฌธ) [์ถœ๋ ฅ]3. N๊ฐœ์˜ ์ˆซ์ž ์ค‘ X๋ณด๋‹ค ์ž‘์€ ์ˆ˜๋งŒ ์ถœ๋ ฅํ•œ๋‹ค. โœ… ์ฝ”๋“œimport java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("N ์ž…๋ ฅ >> "); int n = sc.nextInt(); System.out.print("X ์ž…๋ ฅ >> "); int x = sc.nextInt(); int[] nums = new int[n]; for (int ..
โœ… ๋ฌธ์ œ ํ˜„์žฌ ๋ชธ๋ฌด๊ฒŒ์™€ ๋ชฉํ‘œ ๋ชธ๋ฌด๊ฒŒ๋ฅผ ๊ฐ๊ฐ ์ž…๋ ฅ ๋ฐ›๊ณ  ์ฃผ์ฐจ ๋ณ„ ๊ฐ๋Ÿ‰ ๋ชธ๋ฌด๊ฒŒ๋ฅผ ์ž…๋ ฅ ๋ฐ›์•„ ๋ชฉํ‘œ ๋‹ฌ์„ฑ ์‹œ ์ถ•ํ•˜๋ฉ”์„ธ์ง€๋ฅผ ๋„์šฐ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๊ตฌํ˜„ํ•˜์‹œ์˜ค โœ… ์ถ”๋ก  ๊ณผ์ • ์ผ๋‹จ ์ž…๋ ฅ ๋ฐ›์•„์•ผ ํ•  ๊ฒƒ์ด 3๊ฐ€์ง€์ด๋‹ค. ํ˜„์žฌ๋ชธ๋ฌด๊ฒŒ, ๋ชฉํ‘œ๋ชธ๋ฌด๊ฒŒ, n์ฃผ์ฐจ ๊ฐ๋Ÿ‰ ๋ชธ๋ฌด๊ฒŒ โ€‹ ํ˜„์žฌ๋ชธ๋ฌด๊ฒŒ์™€ ๋ชฉํ‘œ๋ชธ๋ฌด๊ฒŒ๋Š” ์‰ฝ๊ฒŒ ์ž…๋ ฅ ๋ฐ›์•„ ์ฃผ๋Š”๋ฐ (์—ฌ๊ธฐ์„œ System.out.println์„ ์•ˆ ์“ด ์ด์œ ๋Š” ์ฝ˜์†”์ฐฝ์—์„œ ์ž…๋ ฅ ๋ฐ›์„ ๋•Œ ์•Œ์•„์„œ ์ค„ ๋ฐ”๊ฟˆ์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.) โ€‹ ๋ชฉํ‘œ ๋ชธ๋ฌด๊ฒŒ์— ๋„๋‹ฌํ•˜๊ธฐ๊นŒ์ง€ ๋ช‡ ์ฃผ๊ฐ€ ๊ฑธ๋ฆด ์ง€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ๋Ÿ‰ ๋ชธ๋ฌด๊ฒŒ๋Š” ๋ฐ˜๋ณต์ ์œผ๋กœ ๋ช‡ ๋ฒˆ ์ž…๋ ฅ์ด ๋“ค์–ด์˜ฌ ์ง€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์— ์กฐ๊ฑด ๋‹ฌ์„ฑ ์ „๊นŒ์ง€ ๊ณ„์† ๋ฐ˜๋ณต๋˜๋Š” while ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉ ํ•ด ์คฌ๋‹ค. โ€‹ while๋ฌธ์ด ๊ณ„์† ๋Œ๋‹ค๊ฐ€ ํ˜„์žฌ ๋ชธ๋ฌด๊ฒŒ๊ฐ€ ๋ชฉํ‘œ๋ชธ๋ฌด๊ฒŒ์™€ ๊ฐ™๊ฑฐ๋‚˜ ์ž‘์•„์ง€๋ฉด break๋ฅผ ๋งŒ๋‚˜ ์ž…๋ ฅ์ด ์ข…๋ฃŒ๋˜๊ณ ..
์ธ์ ˆ๋ฏธ์˜€๋˜๊ฒƒ
'์ž…๋ ฅ' ํƒœ๊ทธ์˜ ๊ธ€ ๋ชฉ๋ก
์ƒ๋‹จ์œผ๋กœ