import java.util.*;
public class CNumInWords {
public static void main (String[] args)
{
int n = Integer.parseInt(args[0]);
for (int i = n ; i < n+20; i++)
{
System.out.println(numberInWordsDE(i));
System.out.println( wordsToNumberDE(numberInWordsDE(i)) );
}
}
public static String numberInWordsDE(int Zahl)
{
String strLower20[] = {"","ein","zwei","drei","vier","fünf",
"sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn",
"vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn",
"neunzehn"};
String strTenth[] = {"","zehn","zwanzig","dreißig",
"vierzig","fünfzig","sechzig","siebzig","achtzig",
"neunzig","hundert"};
String strOrder[] = {"","tausend","million","milliarde","billion"};
String strExtend[] = {"s"," ",""," ","e","en ","e","n ","e","en "};
String strOut = "";
String strReturn = "";
String strAppend = "";
if (Zahl == 0) return "Null";
if (Zahl < 0) return
"Zahl liegt nicht im gültigen Bereich! {0-2147483647}";
int intRemaining = Zahl;
int intA = 0;
int intB = 0;
int intOrder = 0;
while (intRemaining > 0)
{
strAppend = strExtend[ intOrder*2 + 1 ];
strOut = "";
intA = intRemaining % 1000;
intRemaining = intRemaining / 1000;
if (intA > 99) strOut = strOut + strLower20[intA/100] + strTenth[10];
intB = intA % 100;
if (intB > 19)
{
if ((intB % 10) > 0 )
{ strOut = strOut + strLower20[intB % 10] + "und" ;
}
strOut = strOut + strTenth[intB / 10];
}
else
{
if (intB > 0) strOut = strOut + strLower20[intB];
if (intB == 1)
{ strOut = strOut + strExtend[intOrder*2];
strAppend = " ";
}
}
strOut = strOut + strOrder[intOrder] + strAppend;
intOrder++;
strReturn = strOut + strReturn;
}
return strReturn;
}
public static int wordsToNumberDE(String zahlwort)
{
String strOrder[] = {"#","TAUSEND","MILLION","MILLIARDE"};
String strRest = "";
String strTeil = "";
String strNach100 = "";
int intfaktor = 1000000000;
int intEiner = 0;
int intZahl = 0;
int inttripple = 0;
int intO = 3;
int intP = 0;
String strRemain = zahlwort.toUpperCase();
strRemain = strRemain.replaceAll("[^A-ZÖÜß]","");
while ( ! strRemain.equals("") )
{
if (intO == 0) strRemain = strRemain +"#";
inttripple = 0;
intP = strRemain.indexOf(strOrder[intO]);
if (intP >= 0)
{
strTeil = zeichenVor(strRemain,strOrder[intO]);
strRemain = zeichenNach(strRemain,strOrder[intO]);
strNach100 = strTeil;
if (strTeil.indexOf("HUNDERT")>=0)
{
strNach100 = zeichenNach(strTeil,"HUNDERT");
intEiner = wordToDigitDE(zeichenVor(strTeil,"HUNDERT"));
if (intEiner == 0) intEiner = 1;
inttripple = inttripple + 100 * intEiner;
};
if (strNach100.indexOf("UND") >=0)
{
inttripple += wordToDigitDE(zeichenVor(strNach100,"UND"));
strNach100 = zeichenNach(strNach100,"UND");
};
if (strNach100.indexOf("IG") >=0)
{
if (strNach100.indexOf("ZWANZIG")>=0) inttripple += 20 ;
inttripple += 10 * wordToDigitDE(zeichenVor(strNach100,"IG"));
strNach100 = zeichenNach(strNach100,"IG");
};
if (strNach100.indexOf("ZEHN") >=0)
{
inttripple += 10;
intEiner = wordToDigitDE(zeichenVor(strNach100,"ZEHN"));
if (intEiner > 2) inttripple += intEiner;
}
else
{
inttripple += wordToDigitDE(strNach100);
if (strNach100.indexOf("ELF")>=0) inttripple += 11 ;
if (strNach100.indexOf("ZWÖLF")>=0) inttripple += 12 ;
}
if (intfaktor > 1 && inttripple == 0) inttripple = 1;
};
intZahl += inttripple * intfaktor;
intfaktor = intfaktor/1000;
intO -= 1;
}
return intZahl;
}
private static int wordToDigitDE(String einerzahlwort)
{
if (einerzahlwort.indexOf("EIN") >= 0) return 1;
if (einerzahlwort.indexOf("ZWEI") >= 0) return 2;
if (einerzahlwort.indexOf("DREI") >= 0) return 3;
if (einerzahlwort.indexOf("VIER") >= 0) return 4;
if (einerzahlwort.indexOf("FÜNF") >= 0) return 5;
if (einerzahlwort.indexOf("SECH") >= 0) return 6;
if (einerzahlwort.indexOf("SIEB") >= 0) return 7;
if (einerzahlwort.indexOf("ACHT") >= 0) return 8;
if (einerzahlwort.indexOf("NEUN") >= 0) return 9;
return 0;
}
private static String zeichenVor(String zeile,String trennwort)
{
String strOut = "";
int intP = zeile.indexOf(trennwort);
if (intP >= 0) strOut = zeile.substring(0,intP);
return strOut;
}
private static String zeichenNach(String zeile,String trennwort)
{
String strOut = "";
int intP = zeile.indexOf(trennwort) + trennwort.length();
if (intP < zeile.length())
strOut = zeile.substring(intP,zeile.length());
return strOut;
}
}