Last active
August 29, 2015 14:08
-
-
Save Exloki/043ab7d3d5f28892bcbe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
int main(){ | |
int in; | |
int numbers[4]; | |
in = 1; | |
while(in == 1){ | |
cout << "Geben Sie eine 4 stellige Zahl ein: "; | |
cin >> in; | |
if (in < 9999 && in > 999){ | |
numbers[0] = in % 10; | |
numbers[1] = in / 10 % 10; | |
numbers[2] = in / 100 % 10; | |
numbers[3] = in / 1000 % 10; | |
const char* numberWord[11] = {"Null", "Eins", "Zwei", "Drei", "Vier", "Fuenf", "Sechs", "Sieben", | |
"Acht", "Neun"}; | |
for(int i = 3; i >= 0; i--) | |
{ | |
int value = numbers[i]; | |
if(i == 0) | |
cout << numberWord[value] << endl; | |
else | |
cout << numberWord[value] << "-"; | |
} | |
} else { | |
cout << "Zahl muss 4 Stellen haben"; | |
} | |
cout << "Um das Programm neuzustarten geben sie 1 ein, eine andere Zahl um es zu beenden" << endl; | |
cin >> in; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment