-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroom_number.cpp
More file actions
50 lines (38 loc) · 806 Bytes
/
room_number.cpp
File metadata and controls
50 lines (38 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <vector>
using namespace std;
int input_set[8];
int main(void){
int i, n;
vector<int> number;
cin >> n;
while(1){
if(n/10 != 0){
number.push_back(n%10);
n /= 10;
}
if(n/10 == 0){
number.push_back(n%10);
break;
}
}
for(i = 0; i < number.size(); i++){
if(number[i] == 9){
input_set[6] += 1;
} else {
input_set[number[i]] += 1;
}
}
if(input_set[6] % 2 != 0){
input_set[6] += 1;
}
input_set[6] /= 2;
int max = input_set[0];
for(i = 1; i < 8; i++){
if(input_set[i] > max){
max = input_set[i];
}
}
cout << max << '\n';
return 0;
}