알고리즘

C++ 알고리즘 - 백준 31403 A + B - C

마루설아 2024. 12. 14. 17:44

https://www.acmicpc.net/problem/31403

 

#include <iostream>
#include <string>
using namespace std;

int main(void) {
	// C++ Init
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int input1, input2, input3;
	cin >> input1 >> input2 >> input3;

	cout << input1 + input2 - input3 << "\n";

	string str = to_string(input1) + to_string(input2);
	cout << stoi(str) - input3;
}

 

to_string

정수를 문자/문자열로 변환 (string 헤더파일)

 

stoi

문자/문자열을 정수로 변환