★ solved.ac 난이도 : B4
(작성 시점 기준)
[문제 본문 링크]
10797번: 10부제
서울시는 6월 1일부터 교통 혼잡을 막기 위해서 자동차 10부제를 시행한다. 자동차 10부제는 자동차 번호의 일의 자리 숫자와 날짜의 일의 자리 숫자가 일치하면 해당 자동차의 운행을 금지하는
www.acmicpc.net
★ 풀이
첫 줄에 주어진 숫자가 등장하는 횟수를 세는 문제입니다.
배열로도 풀 수 있지만, 반복문으로도 풀 수 있습니다.
[소스 코드]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main(void){ | |
ios::sync_with_stdio(0); | |
cin.tie(0); | |
int N,A=0; | |
cin>>N; | |
for(int i=0;i<5;i++){ | |
int digit; | |
cin>>digit; | |
if(digit==N) A++; | |
} | |
cout<<A; | |
return 0; | |
} |
★ 틀린 점이 있다면 알려주세요~!