전체 코드
#include <string>
#include <vector>
using namespace std;
int solution(int age) {
int answer = 2022-age+1;
return answer;
}
풀이
- answer에 2022-age+1대입
- 2022년도 기준이므로 2022에 age를 뺌
- 태어났을때부터 1살 취급하므로 +1 더해야함
int solution(int age) {
int answer = 2022-age+1;
return answer;
}
'프로그래머스 코딩테스트 입문(C++)' 카테고리의 다른 글
프로그래머스 7) 두 수의 합 (Lv. 0) (C++) (0) | 2023.03.14 |
---|---|
프로그래머스 6) 몫 구하기 (Lv. 0) (C++) (0) | 2023.03.14 |
프로그래머스 4) 숫자 비교하기 (Lv. 0) (C++) (0) | 2023.03.14 |
프로그래머스 3) 두 수의 곱 (Lv. 0) (C++) (0) | 2023.03.14 |
프로그래머스 2) 나머지 구하기 (Lv. 0) (C++) (0) | 2023.03.14 |