ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [1001๋ฒˆ] A-B
    SW/BAEKJOON(online judge) 2023. 6. 7. 14:02

     ์•„๋ž˜๋Š” Python ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ , A-B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ์˜ˆ์‹œ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

      A = int(input("์ฒซ ๋ฒˆ์งธ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”: "))
      B = int(input("๋‘ ๋ฒˆ์งธ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”: "))

      result = A - B
      print("A์™€ B์˜ ์ฐจ๋Š”", result, "์ž…๋‹ˆ๋‹ค.")



     ์ด ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ๋‘ ๊ฐœ์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ , ์ฒซ ๋ฒˆ์งธ ์ •์ˆ˜์—์„œ ๋‘ ๋ฒˆ์งธ ์ •์ˆ˜๋ฅผ ๋บ€ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

     ํ•˜์ง€๋งŒ ๋ฐฑ์ค€์‚ฌ์ดํŠธ์— ์ž…๋ ฅํ•ด๋ณด๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ์ด์œ ๋Š” ์‹ค์ œ ๋ฌธ์ œ์—์„  ํ•œ ์ค„์—์„œ 2๊ฐœ์˜ ์ˆ˜๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ  ์žˆ๊ณ , ๊ทธ ๊ฒฐ๊ณผ ๊ฐ’์ธ ์ˆซ์ž๋งŒ ์ถœ๋ ฅํ•˜๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

    a, b = map(int, input().split())
    print(a-b)

     ์œ„์™€ ๊ฐ™์€ ์ฝ”๋“œ๋กœ ๋ณ€ํ˜•ํ•˜์—ฌ ์ œ์ถœํ–ˆ์„ ๋•Œ ์ •๋‹ต์œผ๋กœ ์ธ์ •๋ฉ๋‹ˆ๋‹ค.

    'SW > BAEKJOON(online judge)' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

    [1002๋ฒˆ] ํ„ฐ๋ ›  (0) 2023.06.07
    [1000๋ฒˆ] A+B  (0) 2023.06.07

    ๋Œ“๊ธ€

Designed by Tistory.