#include<iostream>
#include<string>
using namespace std;
string units [20] = {"","One ","Two ","Three ","Four ", "Five ","Six ","SEven ","Eight ","Nine ","Ten ","Eleven ", "Twelve ","Thirteen ","Fourteen ","Fifteen ","Sixteen ","Seventeen ","Eighteen ","Nineteen "};
string tens[] = {"","","Twenty ","Thirty ","Fourty ","Fifty ","Sixty ","Seventy ","Eighty ","Ninty "};
string digits[] = {"","","","Hundred ","Thousand ","Thousand ","Lakh ","Lakh ","Crore "};
string getOneDigit(int val, int index) {
if(val < 10) {
string res = units[val];
if(val != 0) {
res = res + digits[index];
}
return res;
}
return "";
}
string getTensDigit(int val, int index) {
if(val < 10) {
string res = tens[val] + digits[index];
return res;
}
return "";
}
string getTwoDigit(int val, int index) {
string res = ""; int temp = val;
if(val < 20) {
res = units[val] + res;
}
else {
res = getOneDigit(val%10,0) + res;
val = val /10;
res = getTensDigit(val %10, 1) + res;
}
if(temp != 0)
res = res + digits[index];
return res;
}
string convertToString(int n) {
string result = "";
int i = 1, r;
while(n) {
if(i != 3) {
r = n %100;
result = getTwoDigit(r,i) + result;
n = n / 100;
i = i+2;
}
else if(i == 3) {
r = n %10;
result = getOneDigit(r, i) + result;
n = n / 10;
i++;
}
}
return result;
}
int main() {
int n, t;
cin>>t;
while(t--) {
cout<<"Entet the number to be converted: ";
cin>>n;
cout<<"Result : "<<convertToString(n)<<endl;
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cmluZyB1bml0cyBbMjBdID0geyIiLCJPbmUgIiwiVHdvICIsIlRocmVlICIsIkZvdXIgIiwgIkZpdmUgIiwiU2l4ICIsIlNFdmVuICIsIkVpZ2h0ICIsIk5pbmUgIiwiVGVuICIsIkVsZXZlbiAiLCAiVHdlbHZlICIsIlRoaXJ0ZWVuICIsIkZvdXJ0ZWVuICIsIkZpZnRlZW4gIiwiU2l4dGVlbiAiLCJTZXZlbnRlZW4gI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JlczsKICAgIH0KICAgIGlmKHRlbXAgIT0gMCkgCiAgICAgICAgcmVzID0gcmVzICArIGRpZ2l0c1tpbmRleF07CiAgICByZXR1cm4gcmVzOwp9CgoKCnN0cmluZyBjb252ZXJ0VG9TdHJpbmcoaW50IG4pIHsKICAgICAgICBzdHJpbmcgcmVzdWx0ID0gIiI7CiAgICAgICAgaW50IGkgPSAxLCByOwoKCiAgICAgICAgd2hpbGUobikgewogICAgICAgICAgICBpZihpICE9IDMpIHsKICAgICAgICAgICAgICAgIHIgPSBuICUxMDA7CiAgICAgICAgICAgICAgICByZXN1bHQgPSBnZXRUd29EaWdpdChyLGkpICsgcmVzdWx0OwogICAgICAgICAgICAgICAgbiA9IG4gLyAxMDA7CiAgICAgICAgICAgICAgICBpID0gaSsyOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgaWYoaSA9PSAzKSB7CiAgICAgICAgICAgICAgICByICA9IG4gJTEwOwogICAgICAgICAgICAgICAgcmVzdWx0ID0gZ2V0T25lRGlnaXQociwgaSkgKyByZXN1bHQ7CiAgICAgICAgICAgICAgICBuID0gbiAvIDEwOwogICAgICAgICAgICAgICAgaSsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIAogICAgICAgIH0KCiAgICByZXR1cm4gcmVzdWx0Owp9CgoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgdDsKICAgIGNpbj4+dDsKICAgIHdoaWxlKHQtLSkgewogICAgICAgIGNvdXQ8PCJFbnRldCB0aGUgbnVtYmVyIHRvIGJlIGNvbnZlcnRlZDogIjsKICAgICAgICBjaW4+Pm47CiAgICAgICAgY291dDw8IlJlc3VsdCA6ICI8PGNvbnZlcnRUb1N0cmluZyhuKTw8ZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==