-
Notifications
You must be signed in to change notification settings - Fork 0
/
32_B_borze.cpp
47 lines (41 loc) · 1.14 KB
/
32_B_borze.cpp
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
/*
B. Borze
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its representation in Borze alphabet.
Input
The first line contains a number in Borze code. The length of the string is between 1 and 200 characters. It's guaranteed that the given string is a valid Borze code of some ternary number (this number can have leading zeroes).
Output
Output the decoded ternary number. It can have leading zeroes.
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string number;
cin >> number;
int i{0};
while(i < number.length()) {
if(number[i] == '.') {
cout << "0";
}
else if(number[i]=='-' && number[i+1]=='.') {
cout << "1";
i = i + 1;
}
else if(number[i]=='-' && number[i+1]=='-') {
cout << "2";
i = i + 1;
}
i++;
}
}