Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public NumberToText(const only_number[], const outputString[])
- {
- new one_array[10][11] = {
- " ","one ", "two ", "three ", "four ", "five ","six ", "seven ", "eight ", "nine "
- };
- new ten_array[10][11] = {
- "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ", "sixteen ",
- "seventeen ", "eighteen ", "nineteen "
- };
- new twenty_array[10][11] = {
- " "," ","twenty ", "thirty ", "fourty ", "fifty ", "sixty ", "seventy ", "eighty ", "ninety "
- };
- new big_unit_array[22][20] = {"vigintillion","novemdecillion","octodecillion","septendecillion",
- "sexdecillion","quindecillion","quattuordecillion","tredecillion",
- "duodecillion","undecillion","decillion","nonillion","octillion",
- "septillion","sextillion","quintillion","quadrillion","trillion ",
- "billion ", "million ", "thounsand ", "hundred "};
- #define MaxUnit 21
- new tempString[150][20];
- //E.g. 1,234,567,890,123
- new i; //for only_number
- new j; //for tempString
- new rem;
- new sizeofNumber = strlen(only_number);
- new tflag = 0;
- for(i = 0,j = 0; i<sizeofNumber; i++)
- {
- rem = (sizeofNumber-i)%3;
- if(!rem)
- tflag = 0;
- if(only_number[i] != '0')
- {
- if(rem == 1) //in oneth position
- {
- strmid(tempString[j++],one_array[only_number[i]-48]);
- tflag = 1;
- }
- else if(rem == 2)
- { //in tenth position
- if(only_number[i] == '1')
- strmid(tempString[j++],ten_array[only_number[++i]-48]);
- else
- strmid(tempString[j++],twenty_array[only_number[i]-48]);
- tflag = 1;
- }
- else if(rem == 0)
- {// in hundredth position
- strmid(tempString[j++],one_array[only_number[i]-48]);
- strmid(tempString[j++],big_unit_array[MaxUnit]);
- tflag = 1;
- }
- }
- if(tflag)
- {
- switch(sizeofNumber-i)
- {
- case 64: { strmid(tempString[j++],big_unit_array[MaxUnit-21]); break; }
- case 61: { strmid(tempString[j++],big_unit_array[MaxUnit-20]); break; }
- case 58: { strmid(tempString[j++],big_unit_array[MaxUnit-19]); break; }
- case 55: { strmid(tempString[j++],big_unit_array[MaxUnit-18]); break; }
- case 52: { strmid(tempString[j++],big_unit_array[MaxUnit-17]); break; }
- case 49: { strmid(tempString[j++],big_unit_array[MaxUnit-16]); break; }
- case 46: { strmid(tempString[j++],big_unit_array[MaxUnit-15]); break; }
- case 43: { strmid(tempString[j++],big_unit_array[MaxUnit-14]); break; }
- case 40: { strmid(tempString[j++],big_unit_array[MaxUnit-13]); break; }
- case 37: { strmid(tempString[j++],big_unit_array[MaxUnit-12]); break; }
- case 34: { strmid(tempString[j++],big_unit_array[MaxUnit-11]); break; }
- case 31: { strmid(tempString[j++],big_unit_array[MaxUnit-10]); break; }
- case 28: { strmid(tempString[j++],big_unit_array[MaxUnit-9]); break; }
- case 25: { strmid(tempString[j++],big_unit_array[MaxUnit-8]); break; }
- case 22: { strmid(tempString[j++],big_unit_array[MaxUnit-7]); break; }
- case 19: { strmid(tempString[j++],big_unit_array[MaxUnit-6]); break; }
- case 16: { strmid(tempString[j++],big_unit_array[MaxUnit-5]); break; }
- case 13: { strmid(tempString[j++],big_unit_array[MaxUnit-4]); break; }
- case 10: { strmid(tempString[j++],big_unit_array[MaxUnit-3]); break; }
- case 7 : { strmid(tempString[j++],big_unit_array[MaxUnit-2]); break; }
- case 4 : { strmid(tempString[j++],big_unit_array[MaxUnit-1]); break; }
- }
- }
- }
- j--;
- strmid(outputString,tempString[0]);
- for(new i=1; new i<=j; i++)
- strcat(outputString, tempString[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement