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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
#include <iostream>
#include <string>
using namespace std;
struct str {
char alpha;
string morse;
};
// Global data. Each valid character and its equivalent
// morse code are stored in the parallel arrays.
const int NUM_CHARS = 40;
const char alpha[NUM_CHARS] = { ' ', ',', '.', '?', '0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
};
const string morseCode[NUM_CHARS] = { " ", "--..--" , ".-.-.-" , "..--.." ,
"-----", ".----", "..---", "...--",
"....-", ".....", "-....", "--...",
"---..", "----.", ".-", "-...",
"-.-.", "-..", ".", "..-.",
"--.", "....", "..", ".---",
"-.-", ".-..", "--", "-.",
"---", ".--.", "--.-", ".-.",
"...", "-", "..-", "...-",
".--", "-..-", "-.--", "--.."
};
string getInput();
string textTOmorse();
int main()
{
string temp;
string upperTemp;
int locations[NUM_CHARS];
str strArray[NUM_CHARS];
for(int i = 0; i < (NUM_CHARS-1); i++)
{
strArray[i].alpha = alpha[i];
strArray[i].morse = morseCode[i];
}
for(int i = 0; i < NUM_CHARS; i++)
{
cout << strArray[i].alpha << " = " << strArray[i].morse << endl;
}
cout << endl;
//getInput();
//textTOmorse();
//cout << upperTemp << endl;
//cout << "These are the values stored in the location array: " << endl;
// for(int i = 0; i < NUM_CHARS; i++)
// {
// cout << locations[i] << endl;
// }
//
return 0;
}
//string getInput()
//{
// cout << "Enter your text to be stored: " << endl;
//
// getline(cin, temp);
// for(size_t index=0; index<temp.size(); index++)
// {
// upperTemp += toupper(temp[index]); //Uppercases one letter at a time and copies to the temp1 string
// }
// return upperTemp;
//}
//
//string textTOmorse()
//{
// int count = 0;
// for(size_t index=0; index<upperTemp.size(); index++)
// {
// if(upperTemp[count] != alpha[index])
// {
// continue;
// }else
// {
// locations[count] = index;
// count += 1;
// }
// }
//
// return 0;
//
//}
|