From cf0df76baa2d84b39f764b0484649c6757c0fa52 Mon Sep 17 00:00:00 2001 From: Rishabh Bhatt Date: Tue, 5 Oct 2021 19:38:01 +0530 Subject: [PATCH] Create keyboard specified sequence : string --- keyboard specified sequence : string | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 keyboard specified sequence : string diff --git a/keyboard specified sequence : string b/keyboard specified sequence : string new file mode 100644 index 0000000..2b0420f --- /dev/null +++ b/keyboard specified sequence : string @@ -0,0 +1,48 @@ +//program to convert string to keyboard specified sequence : love babbar sheet problems + +#include +using namespace std; + +string KeypadSequenceConverter(string str[], string input) +{ + int n=input.size(); + string output=""; + for (int i = 0; i < n;i++) + { + // CHARACTER IS SPACE THEN ADD 0 TO OUTPUT STRING + if(input[i]==' ') + { + output = output + "0"; + } + // otherwise add specified string on the basis of array + else + { + output = output + str[input[i] - 'A']; + } + + } + return output; +} + + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + + + // storing the sequence in array + string str[] = {"2","22","222", + "3","33","333", + "4","44","444", + "5","55","555", + "6","66","666", + "7","77","777","7777", + "8","88","888", + "9","99","999","9999" + }; + + string input = "RISHABH BHATT"; + cout << KeypadSequenceConverter(str, input); + return 0; +}