1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include <iostream>
//#include <math.h>
using namespace std;
char one[10][10] = {"ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"};
char two[10][10] = {"ELVEN", "TWELVE", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVENTEEN", "EIGHTEEN", "NINTEEN" };
char tendigits[10] [10] = {"TEN", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINTY"};
int unit (int num)
{
num ? (cout << one[num-1]):(cout << "ZERO");
return 0;
}
int tens (int num)
{
(num>10 && num<20) ? (cout << two[num-11]) : ((cout << tendigits [num/10-1]) && ((num%10) ? (unit(num%10)):1));
return 0;
}
int hundred (int num)
{
(num/100)? (unit(num/100) && (cout << "HUNDRED\t")):1;
(num % 100)? (tens(num%100)):1;
}
int main ()
{
//cout << one[0];
//unit(3);
//tens(25);
hundred(201);
// return 0;
}
|