-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdecoder.cpp
49 lines (45 loc) · 1.49 KB
/
decoder.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
48
49
#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main()
{
int i,strLength,count;
count = 1;
char inputString[100];
cin >> inputString;
strLength = strlen(inputString);
char A[3]={'A','B','C'},D[3]={'D','E','F'},G[3]={'G','H','I'},J[3]={'J','K','L'},M[3]={'M','N','O'},P[4]={'P','Q','R','S'};
char T[3]={'T','U','V'},W[4]={'W','X','Y','Z'};
for(i = 0; i < strLength; i++)
{
if( inputString[i] == inputString[i+1])
count++;
else
{
switch(inputString[i])
{
case '2': cout << A[count-1];
break;
case '3': cout << D[count-1];
break;
case '4': cout << G[count-1];
break;
case '5': cout << J[count-1];
break;
case '6': cout << M[count-1];
break;
case '7': cout << P[count-1];
break;
case '8': cout << T[count-1];
break;
case '9': cout << W[count-1];
break;
case '0': cout << " ";
break;
default : cout<<"ASDASD";
}
count = 1;
}
}
}