백준 31403번 : A+B-C

M1ndCon·2024년 6월 27일
0

Algorithm

목록 보기
12/32

  • Solved.ac 기준 : 브론즈 4
  • 사용언어 C++

문제 해석 및 풀이

  • 일반 수학계산과 문자열 계산을 나눠서 고려하면 되는 간단한 구현 문제
  • 두 자리 이상의 수가 나올 경우도 고려해야함
#include <iostream>
#include <string>
using namespace std;

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;

	cout << a+b-c << "\n";

	string strA = to_string(a);
	string strB = to_string(b);
	string strAB = strA + strB;
	int res = stoi(strAB) - c;

	cout << res;

	return 0;
}
profile
게임 개발자 지망생

0개의 댓글