daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Nov 18th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void below20(int x)
  6. {
  7.     switch (x){
  8.         case 1: cout << "ein"; break;
  9.         case 2: cout << "zwei"; break;
  10.         case 3: cout << "drei"; break;
  11.         case 4: cout << "vier"; break;
  12.         case 5: cout << "fünf"; break;
  13.         case 6: cout << "sechs"; break;
  14.         case 7: cout << "sieben"; break;
  15.         case 8: cout << "acht"; break;
  16.         case 9: cout << "neun"; break;
  17.         case 10: cout << "zehn"; break;
  18.         case 11: cout << "elf"; break;
  19.         case 12: cout << "zwölf"; break;
  20.         case 13: cout << "dreizehn"; break;
  21.         case 14: cout << "vierzehn"; break;
  22.         case 15: cout << "fünfzehn"; break;
  23.         case 16: cout << "sechzehn"; break;
  24.         case 17: cout << "siebzehn"; break;
  25.         case 18: cout << "achtzehn"; break;
  26.         case 19: cout << "neunzehn"; break;
  27.     }
  28. }
  29.  
  30. void twoDigit (int x)
  31. {
  32.     switch (x){
  33.         case 2: cout << "zwanzig"; break;
  34.         case 3: cout << "dreißig"; break;
  35.         case 4: cout << "vierzig"; break;
  36.         case 5: cout << "fünfzig"; break;
  37.         case 6: cout << "sechzig"; break;
  38.         case 7: cout << "siebzig"; break;
  39.         case 8: cout << "achtzig"; break;
  40.         case 9: cout << "neunzig"; break;
  41.     }
  42. }
  43.  
  44. void numberToWords (int x)
  45. {
  46.  
  47.     if (x == 0)
  48.         cout << "null";
  49.  
  50.     if (x % 1000)
  51.     {
  52.         below20(x/100);
  53.         cout << "hundert";
  54.         x = x % 100;
  55.     }
  56.  
  57.     if (x >= 1 && x <= 19)
  58.     {
  59.         below20(x);
  60.         if (x == 1)
  61.             cout << "s";
  62.     }
  63.     else
  64.         if(x >= 20 && x <= 99)
  65.         {
  66.             if(x % 10 != 0)
  67.             {
  68.                 below20(x%10);
  69.                 cout << "und";
  70.             }
  71.             twoDigit(x/10);
  72.         }
  73. }
  74.  
  75. int main() {
  76.     int x;
  77.     cout << "Bitte Zahl eingeben: \n";
  78.     cin >> x;
  79.     numberToWords(x);
  80.     return 0;
  81. }
RAW Paste Data
Top