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.
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 the decoded ternary number. It can have leading zeroes.
.-.--
012
--.
20
-..-.--
1012#include<cstring> #include<iostream> using namespace std; int main(){ int i,k,len; char s[200],num[200]; while(cin>>s){ memset(num,0,sizeof(num)); k=0; len=strlen(s); for(i=0;i<len;i++){ if(s[i]=='-'){ if(s[i+1]=='-'){ num[k]='2'; } else if(s[i+1]=='.'){ num[k]='1'; } k++; i++; } else if(s[i]=='.'){ num[k]='0'; k++; } } cout<<num<<endl; } return 0; }