72 lines
2.0 KiB
C++
72 lines
2.0 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
#include <cstring>
|
|
#include <stdlib.h>
|
|
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
string morse[36] = {".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..",
|
|
".----","..--","...--","...-",".....","-....","--...","---..","----.","-----"};
|
|
string alpha[36] = {"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","1","2","3","4","5","6","7","8","9","0"};
|
|
int n;
|
|
string a, wynik;
|
|
while (true)
|
|
{
|
|
cout << "\nTen program pozwala na tlumaczenie zdan z kodu morse'a lub na kod morse'a\n Nacisnij 1 jesli chcesz tlumaczyc z kodu morse'a lub 2 jesli chcesz tlumaczyc na kod morse'a.\n Nacisnij 3 jesli chcesz zamknac program\n" << endl;
|
|
cin >> n;
|
|
switch (n)
|
|
{
|
|
case 1:
|
|
a = "";
|
|
wynik = "";
|
|
cout << "\nWpisz jeden znak kodu morse'a a nastepnie kliknij enter, aby wstawic spacje wpisz / i wcisnij enter.\nAby skonczyc przekazywanie i zaczac tlumaczenie nacisnij * i enter." << endl;
|
|
cin >> a;
|
|
while (a != "*")
|
|
{
|
|
for (int i = 0; i < 36; i++)
|
|
{
|
|
if (morse[i] == a)
|
|
{
|
|
wynik += alpha[i];
|
|
}
|
|
}
|
|
if (a == "/")
|
|
{
|
|
wynik += " ";
|
|
}
|
|
cin >> a;
|
|
}
|
|
cout << wynik << endl;;
|
|
break;
|
|
|
|
case 2:
|
|
a = "";
|
|
wynik = "";
|
|
cout << "Wpisz mala litere lub cyfre ktora bedzie tlumaczona na kod morse'a i wcisnij enter, aby zrobic spacje wpisz / i wcisnij enter.\nW przetlumaczonym zdaniu litery beda oddzielone spacja a slowa dwoma tabulatorami.\nAby skonczyc i zaczac tlumaczenie wcisnij * i enter." << endl;
|
|
cin >> a;
|
|
while (a != "*")
|
|
{
|
|
for (int i = 0; i < 36; i++)
|
|
{
|
|
if (alpha[i] == a)
|
|
{
|
|
wynik += morse[i]+ " ";
|
|
}
|
|
}
|
|
if (a == "/")
|
|
{
|
|
wynik += " ";
|
|
}
|
|
cin >> a;
|
|
}
|
|
cout << wynik << endl;
|
|
break;
|
|
case 3:
|
|
exit(3);
|
|
}
|
|
}
|
|
}
|
|
|