코딩로그
[백준/BOJ/C++] 16017번 Telemarketer or not? 본문
[문제]
Here at the Concerned Citizens of Commerce (CCC), we have noted that telemarketers like to use seven-digit phone numbers where the last four digits have three properties. Looking just at the last four digits, these properties are:
- the first of these four digits is an 8 or 9;
- the last digit is an 8 or 9;
- the second and third digits are the same.
For example, if the last four digits of the telephone number are 8229, 8338, or 9008, these are telemarketer numbers.
Write a program to decide if a telephone number is a telemarketer number or not, based on the last four digits. If the number is not a telemarketer number, we should answer the phone, and otherwise, we should ignore it.
[입력]
The input will be 4 lines where each line contains exactly one digit in the range from 0 to 9.
[출력]
Output either ignore if the number matches the pattern for a telemarketer number; otherwise, output answer.
[Source Code]
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int a, b, c, d, check = 0;
cin >> a >> b >> c >> d;
if(a == 8 || a == 9){
if(d == 8 || d == 9){
if(b == c)
check = 1;
}
}
if(check == 1)
cout << "ignore";
else
cout << "answer";
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 10822번 더하기 (0) | 2021.11.01 |
---|---|
[백준/BOJ/C++] 21866번 추첨을 통해 커피를 받자 (0) | 2021.11.01 |
[백준/BOJ/C++] 15814번 야바위 대장 (0) | 2021.11.01 |
[백준/BOJ/C++] 16674번 2018년을 되돌아보며 (0) | 2021.11.01 |
[백준/BOJ/C++] 18883번 N M 찍기 (0) | 2021.11.01 |