C++ sleep time for alphabet equivalent numerical code
I have an alphabet equivalent numerical code in array of string that I
want to be output when a word OR sentence is input. Here is my c++ code
for that. It gets user input & output a beep for equivalent time for all
numerical digit for all alphabets in a full character like morse code. It
has same sleep time for full character equivalent numerical code.
Now I want to add different sleep time between numerical code of different
alphabets so that code for separate alphabet is recognized. Like e.g. beep
for alphabet 'b' has same sleep time for all its equivalent numericals &
then a long beep before any other character following it.
How can I do that?
Here is my code so far:
#include <iostream>
#include <string>
#include <sstream>
#include <windows.h>
using namespace std;
string texttopattern(char c)
{
//Hello world again
//125-15-123-123-135 1346-135-1235-123-145 1-1245-1-24-1345
string alphabet = "abcdefghijklmnopqrstuvwqyz"; //osv
string code[] = {"1","12","14","145", "15", "124", "1245",
"125", "24", "245", "13", "123", "134",
"1345", "135", "1234", "12345", "1235", "234", "2345",
"136", "1236", "1346", "13456", "1356", "12346"};
int index = alphabet.find(c);
if(index!=-1)
return code[index];
else
return " ";
}
int main()
{
int n;
string ord;
getline(cin, ord);
string code="";
for(int i=0; i<ord.length(); i++)
{
code += texttopattern(ord[i]);
}
for(int i = 0; i<code.length(); i++){
n = code[i] - '0';
for(int i=0; i<n; i++){
//cout<<n<<endl;
cout<<'\a';
Sleep(600);//same sleep time for full code of a character
//
}}
return 0;
}
No comments:
Post a Comment