[백준 31654] Adding Trouble (C#, C++) - soo:bak
작성일 :
문제 링크
설명
세 정수 A, B, C가 주어질 때 A+B와 C가 같은지 확인하고, 맞으면 correct!, 아니면 wrong!을 출력하는 문제입니다.
접근법
그대로 읽어 합을 비교하면 됩니다.
Code
C#
1
2
3
4
5
6
7
8
9
10
11
12
using System;
class Program {
static void Main() {
var parts = Console.ReadLine()!.Split();
var a = int.Parse(parts[0]);
var b = int.Parse(parts[1]);
var c = int.Parse(parts[2]);
Console.WriteLine(a + b == c ? "correct!" : "wrong!");
}
}
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int a, b, c; cin >> a >> b >> c;
if (a + b == c) cout << "correct!\n";
else cout << "wrong!\n";
return 0;
}