코딩로그
[백준/BOJ/C++] 17863번 FYI 본문
[문제]
In the United States of America, telephone numbers within an area code consist of 7 digits: the prefix number is the first 3 digits and the line number is the last 4 digits. Traditionally, the 555 prefix number has been used to provide directory information and assistance as in the following examples:
- 555-1212
- 555-9876
- 555-5000
- 555-7777
Telephone company switching hardware would detect the 555 prefix and route the call to a directory information operator. Now-a-days, telephone switching is done digitally and somewhere along the line a computer decides where to route calls.
For this problem, write a program that determines if a supplied 7-digit telephone number should be routed to the directory information operator, that is, the prefix number is 555.
[입력]
The input consists of a single line containing a 7-digit positive integer N, (1000000 <= N <= 9999999).
[출력]
The single output line consists of the word YES if the number should be routed to the directory information operator or NO if the number should not be routed to the directory information operator.
[Source Code]
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int test = 0;
string number;
cin >> number;
for(int i = 0; i < 3; i++){
if(number[i] != '5')
test = 1;
}
if(test == 1)
cout << "NO";
else
cout << "YES";
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 7891번 Can you add this? (0) | 2021.10.22 |
---|---|
[백준/BOJ/C++] 16170번 오늘의 날짜는? (0) | 2021.10.22 |
[백준/BOJ/C++] 17094번 Serious Problem (0) | 2021.10.22 |
[백준/BOJ/C++] 17010번 Time to Decompress (0) | 2021.10.22 |
[백준/BOJ/C++] 20499번 Darius님 한타 안 함? (0) | 2021.10.22 |