[백준 31606] 果物 (Fruit) (C#, C++) - soo:bak
작성일 :
문제 링크
설명
사과와 귤의 개수가 주어질 때, 바나나 3개를 더한 총 과일 개수를 출력하는 문제입니다.
접근법
입력된 X, Y에 3을 더해 X + Y + 3을 출력하면 됩니다.
Code
C#
1
2
3
4
5
6
7
8
9
using System;
class Program {
static void Main() {
var x = int.Parse(Console.ReadLine()!);
var y = int.Parse(Console.ReadLine()!);
Console.WriteLine(x + y + 3);
}
}
C++
1
2
3
4
5
6
7
8
9
10
11
12
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x, y; cin >> x >> y;
cout << x + y + 3 << "\n";
return 0;
}