반응형
https://www.acmicpc.net/problem/19602
19602번: Dog Treats
There are three lines of input. Each line contains a non-negative integer less than 10. The first line contains the number of small treats, S, the second line contains the number of medium treats, M, and the third line contains the number of large treats,
www.acmicpc.net
입출력, if else문을 사용해보는 문제였습니다.
📕 풀이방법
📔 입력 및 초기화
s, m, l, 점수 score를 선언 후 적절히 입력받습니다.
📔 풀이과정
공식을 적용하게되면 score=1∗s+2∗m+3∗l 가 됩니다.
📔 정답출력
score가 10이상이면 happy 아니면 sad를 출력해줍니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
int s, m, l, score;
int main(){
cin >> s >> m >> l;
score = 1 * s + 2 * m + 3 * l;
if(score >= 10) cout << "happy";
else cout << "sad";
}
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - 백준(BOJ) 20352 : Circus (0) | 2021.11.08 |
---|---|
(C++) - 백준(BOJ) 20215 : Cutting Corners (0) | 2021.11.07 |
(C++) - 백준(BOJ) 18414 : X に最も近い値 (The Nearest Value) (0) | 2021.11.04 |
(C++) - 백준(BOJ) 18408 : 3 つの整数 (Three Integers) (0) | 2021.11.02 |
(C++) - 백준(BOJ) 17903 : Counting Clauses (0) | 2021.10.30 |