[백준 13985] Equality (C#, C++) - soo:bak
작성일 :
문제 링크
설명
a + b = c 형식의 등식이 주어질 때, 등식이 성립하는지 판별하는 문제입니다.
접근법
입력을 공백으로 분리해 a, b, c를 파싱합니다.
a + b가 c와 같으면 YES, 아니면 NO를 출력합니다.
Code
C#
1
2
3
4
5
6
7
8
9
10
11
using System;
class Program {
static void Main() {
var line = Console.ReadLine()!.Split();
var a = int.Parse(line[0]);
var b = int.Parse(line[2]);
var c = int.Parse(line[4]);
Console.WriteLine(a + b == c ? "YES" : "NO");
}
}
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b, c; char plus, eq;
cin >> a >> plus >> b >> eq >> c;
cout << (a + b == c ? "YES" : "NO") << "\n";
return 0;
}