#include #include #include #include #include #include #include #include using std::string; using std::map; using std::vector; using namespace boost::assign; string SpellEn(int num) { if (num<0) { return "minus " + SpellEn(-num); } if (num<=19) { vector w; w += "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" , "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"; return w.at(num); } if (num<=99) { vector w; w += "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"; int ten = (num/10); int one = num%10; return w.at(ten-2) + ((one!=0) ? ("-"+SpellEn(one)) : ("")); } if (num<=999) { int hundred = num / 100; int rest = num % 100; return SpellEn(hundred) + " hundred" + ((rest!=0) ? (" "+SpellEn(rest)) : ("")); } if (num<=99*999) { int thousand = num / 1000; int rest = num % 1000; return SpellEn(thousand) + " thousand" + ((rest!=0) ? (" "+SpellEn(rest)) : ("")); } return "???"; } string SpellPl(int num) { if (num<0) { return "minus " + SpellPl(-num); } if (num<=19) { vector w; w += "zero", "jeden", "dwa", "trzy", "cztery", "pięć", "sześć", "siedem", "osiem", "dziewięć", "dziesięć" , "jedenaście", "dwanaście", "trzynaście", "czternaście", "piętnaście", "szesnaście", "siedemnaście", "osiemnaście", "dziewiętnąscie"; return w.at(num); } if (num<=99) { vector w; w += "dwadzieścia", "trzydzieści", "czterdzieści", "pięćdziesiąt", "sześćdziesiąt", "siedemdziesiąt", "osiemdziesiąt", "dziewięćdziesiąt"; int ten = (num/10); int one = num%10; return w.at(ten-2) + ((one!=0) ? (" "+SpellPl(one)) : ("")); } if (num<=999) { int hundred = num / 100; string hundredStr="???"; { vector w; w += "???", "sto", "dwieście", "trzysta", "czterysta", "pięćset", "sześćset", "siedemset", "osiemset", "dziewięćset"; hundredStr = w.at(hundred); }; int rest = num % 100; return hundredStr + ((rest!=0) ? (" "+SpellPl(rest)) : ("")); } if (num<=99*999) { int thousand = num / 1000; string thousandStr=""; if (thousand==1) thousandStr = "tysiąc"; else if (thousand<=4) thousandStr = SpellPl(thousand) + " tysiące"; else thousandStr = SpellPl(thousand) + " tysięcy"; int rest = num % 1000; return thousandStr + ((rest!=0) ? (" "+SpellPl(rest)) : ("")); } return "???"; } void Test(int i) { std::cout << std::setw(5) << i << " is " << SpellEn(i) << std::endl; std::cout << std::setw(5) << i << " to " << SpellPl(i) << std::endl; } int main(int argc, const char** argv) { if (argc>=2) { using std::cout; using std::endl; float num=0; std::istringstream str(argv[1]); str>>num; int full = (int)num; int cent = (int)(0.1 + (num - full) * 100); cout<