BOJ 1001 A-B

1 개요[ | ]

BOJ 1001 A-B

[[분류:BOJ {{{단계}}}단계]]

  • 1단계
  • 두 수의 뺄셈
  • 두 수를 입력받고 뺄셈을 한 결과를 출력하는 문제
  • 알고리즘 분류: 사칙연산

2 C[ | ]

#include <stdio.h>
int main() {
	int a, b;
	scanf("%d %d",&a,&b);
	printf("%d\n",a-b);
	return 0;
}

3 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    auto a=0, b=0;
    cin >> a >> b;
    cout << a-b << endl;
    return 0;
}

4 CMD[ | ]

@echo off
set /p line=
for /f "tokens=1" %%G IN ("%line%") DO set a=%%G
for /f "tokens=2" %%G IN ("%line%") DO set b=%%G
set /a "c=%a%-%b%"
echo %c%

5 C#[ | ]

using System;
public class Program {
    public static void Main() {
        string s = Console.ReadLine();
        string[] ss = s.Split();
        int a = int.Parse(ss[0]);
        int b = int.Parse(ss[1]);
        Console.WriteLine(a-b);
    }
}

6 Go[ | ]

package main
import "fmt"
func main() {
    var a, b int
    fmt.Scanf("%d %d", &a, &b)
    fmt.Printf("%d\n", a-b)
}

7 Java[ | ]

import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a, b;
        a = sc.nextInt();
        b = sc.nextInt();
        System.out.println(a - b);
    }
}

8 node.js[ | ]

var fs = require('fs');
var input = fs.readFileSync('/dev/stdin').toString().split(' ');
var a = parseInt(input[0]);
var b = parseInt(input[1]);
console.log(a-b);

9 Perl[ | ]

my ($a, $b) = split(/ /, <>);
print $a - $b;
$_=<>;
s# #-#;
print eval;

10 PHP[ | ]

<?php
fscanf(STDIN,"%d %d",$a,$b);
fprintf(STDOUT,"%d",$a-$b);

11 Python[ | ]

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

12 R[ | ]

x = scan("stdin")
a = x[1]
b = x[2]
cat( a-b )

13 Ruby[ | ]

a, b = gets.split
puts a.to_i - b.to_i

14 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}