๐Ÿ… ๋ฐฑ์ค€ 1001 : A-B (C++, PHP, Javascript)

๋ฌธ์ œ

๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A-B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— A์™€ B๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (0 < A, B < 10)

์ถœ๋ ฅ

์ฒซ์งธ ์ค„์— A-B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

์˜ˆ์ œ ์ž…๋ ฅ

3 2

์˜ˆ์ œ ์ถœ๋ ฅ

1

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ถ„๋ฅ˜

  • ์ˆ˜ํ•™
  • ๊ตฌํ˜„
  • ์‚ฌ์น™์—ฐ์‚ฐ

ํ’€์ด

ํ•œ์ค„๋กœ ์ž…๋ ฅ๋œ ๋‘ ์ˆซ์ž๋ฅผ ๊ตฌํ•˜๊ณ  ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค

PHP
<?
fscanf(STDIN, "%d %d", $a, $b);
echo $a - $b;
CPP
#include <iostream>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << a - b;
    return 0;
}
JavaScript
const fs = require('fs');
const inputData = fs.readFileSync(0, 'utf8').toString().split(' ');
const a = parseInt(inputData[0]), b = parseInt(inputData[1]);
console.log(a - b);

์ˆ์ฝ”๋”ฉ ํ’€์ด

์ฃผ์–ด์ง„ ์ˆซ์ž๊ฐ€ ํ•œ์ž๋ฆฌ์ˆ˜์ธ ์ ์„ ์ด์šฉ ํ•ด ์ž…๋ ฅ์„ ๋ฌธ์ž์—ด๋กœ ์ฒ˜๋ฆฌํ•˜๋ฉด ๋” ์งง๊ฒŒ ์ฒ˜๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•˜๋‹ค.

PHP
<?=($_=fgets(STDIN))[0]-$_[2];