Code:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
using namespace std;
string morse(string a);
int main()
{
string ord;
cout<< "\nwrite your morsecode " <<endl;
cin>>ord;
cout<<"the morse code decrypted is "<<morse(ord);
system("PAUSE");
return 0;
}
string morse(string a)
{
char g;
string z[30]={".- ","-... ","-.-. ","-.. ",". ","..-. ","--. ",".... ",".. ",".--- "
,"-.- ",".-.. ","-- ","-. ","--- ",".--. ","--.- ",".-. ","... ","- "
,"..- ","...- ",".-- ","-..- ","--.. ",".--.- ",".-.- ","---. "};
string u[30]={"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","Å","Ä","Ö"};
string klart="";
for (int i = 0;i <a.size();i++)
{
char f =a [i];
for (int j = 0; j <=29;j++)
{
string tmp=z[j];
g=tmp[0];
if(g==f)
{
klart=klart +u[j];
}
}
}
return klart;
}