티스토리 뷰

Baekjoon Solutions/Class-1

[백준] A+B(1000번)

률무차 2021. 3. 10. 02:44

title: "A+B(1000번)"
category: 백준[Class-1]
tags: [C++, JavaScript, 백준]
date: "2021-03-10"


문제 링크

A+B(1000번)

C++

#include <iostream>

using namespace std;

// 문제 풀이
void solution(){
    // cin 조절
    int a=0, b=0;
    cin >> a >> b;

    cout << a + b;
}

bool exists(const char* fileName){
    FILE* fp;
    if((fp = fopen(fileName, "r"))){
        fclose(fp);
        return true;
    }
    return false;
}

int main() {
    if(exists("stdin")){
        freopen("stdin", "r", stdin);
        solution();
        fclose(stdin);
    }
    else{
        solution();
    }

    return 0;
}

JavsScript

const fs = require("fs");
// split 조절
const input = fs.readFileSync("dev/stdin").toString().split(" ");

// 문제 풀이
console.log(+input[0] + +input[1]);
728x90
반응형

'Baekjoon Solutions > Class-1' 카테고리의 다른 글

[백준] 문자열 반복(2675번)  (0) 2021.03.12
[백준] 최댓값(2562번)  (0) 2021.03.12
[백준] 별 찍기 - 1(2438번)  (0) 2021.03.12
[백준] A-B(1001번)  (0) 2021.03.10
[백준] 두 수 비교하기(1330번)  (0) 2021.03.10
댓글
05-14 16:10
링크