-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBorze.cpp
More file actions
52 lines (47 loc) · 1.28 KB
/
Copy pathBorze.cpp
File metadata and controls
52 lines (47 loc) · 1.28 KB
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
51
52
/*Borze
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
Examples
inputCopy
.-.--
outputCopy
012
inputCopy
--.
outputCopy
20
inputCopy
-..-.--
outputCopy
1012
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a;
string st1;
cin>>st1;
int i=0;
while(i<st1.size()){
if(st1[i]=='.' && st1[i-1]!='-' || st1[i]=='.' && st1[i-1]=='-' && st1[i-2]=='-' ){
cout<<"0";
i=i+1;
}
if(st1[i]=='-' && st1[i+1]=='.'){
cout<<"1";
i=i+2;
}
if(st1[i]=='-' && st1[i+1]=='-'){
cout<<"2";
i=i+2;
}
}
return 0;
}