Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created July 9, 2020 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/5c662bff34c8bca57a9702cc7e57820e to your computer and use it in GitHub Desktop.
Save BMU-Verlag/5c662bff34c8bca57a9702cc7e57820e to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <string.h>
using namespace std;
int main(int argc, char *argv[])
{
char grossbuchstaben[42] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ\216\231\232\3411234567890";
char kleinbuchstaben[42] = " abcdefghijklmnopqrstuvwxyz\204\224\201\3411234567890";
string morsezeichen[41] = {" ", ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",
".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-",
".--", "-..-", "-.--", "--..", ".-.-", "---.", "..--", "...--..", ".----", "..---", "...--",
"....-", ".....", "-....", "--...", "---..", "----.", "-----"};
string eingabe;
string ausgabe = "";
cout << "Geben Sie den Text ein, den Sie \201bersetzen wollen:\n";
getline(cin, eingabe);
int i;
for(i = 0; i < eingabe.length(); i++){
int j = 0;
bool weiter = true;
while(weiter && j < 42){
if(grossbuchstaben[j] != eingabe[i] && kleinbuchstaben[j] != eingabe[i]){
j++;
}
else{
weiter = false;
}
}
if (j < 42){
ausgabe += morsezeichen[j] + " ";
}
}
cout << ausgabe;
for(i = 0; i < ausgabe.length() - 1; i++){
if(ausgabe[i] == '.'){
Beep(600,500);
}
else if(ausgabe[i] == '-'){
Beep(600,1000);
}
else if(ausgabe[i] == ' '){
Sleep(1000);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment