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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#define sstr substr
#define instr find
#include <iostream>
#include <string>
void print(std::string);std::string l(std::string);std::string strw(int);int get(char);
int main(int argc, char *argv[]){for(int i=1; i<argc; i++) print(argv[i]);return 0;}
void print(std::string s){std::string t=s, str="", a=strw(0),b;while(t[0]=='0')t.erase(0,1);
while(t.instr(",")!=std::string::npos) t.erase(t.instr(","),1);int d=t.instr(".");
bool r=(t[0]=='$'), j=((d!=(int)std::string::npos)?true:false); if(r) t=t.sstr(1,t.size()-1);
d=t.instr(".");a=t.sstr(0,((int)t.size()-1<d)?t.size():d);if(d!=(int)std::string::npos)
b=(t.sstr(d+1)+"0").sstr(0,2);int k=20;for(int i=a.size()-1; i>1; i=i-3){if(a.sstr(i-2,3)!="000")
str=l(a.sstr(i-2,3))+strw(247)+strw(get((char)(k+48)))+strw(247)+str;k=k+(k<=23?1:0);}
d=(a.size()%3);if(d!=0) str=l(a.sstr(0,d))+strw(247)+strw(get(k+48))+strw(247)+str;if(str.empty())
str=strw(get((char)48))+(char)32;if(r) str+=strw(145);while(str.instr(strw('{'*2))!=std::string::npos)
str.erase(str.instr(strw('{'*2)),1);if(str==strw('h'+'1')) str=str.sstr(0,str.size()-1);if(j){
if(b!="0"&&b!="00") str+=strw('A'+'d')+l(b)+(r?(strw('d'+'G')):"");else if(r) str+=strw('Y'*2);
else str+=strw(165)+strw(0);if(str.instr(strw('a'*2))!=std::string::npos&&str.instr(strw('f'*2))
==std::string::npos) str=str.sstr(0,str.size()-1);}if(str.sstr(str.size()-1,1).compare(strw(247))==0)
str=str.sstr(0,str.size()-1);while(str.instr(strw('{'*2))!=std::string::npos)str.erase(str.instr(strw('{'*2)),1);
std::cout << (char)toupper(str[0]) << str.sstr(1,str.size()-1) << ".\n";}std::string l(std::string s){
std::string str="00"+s;char a=str[str.size()-1], b=str[str.size()-2], c=str[str.size()-3];
str=std::string(((a-48!=0)?strw(get(a)):""));if(b-48==1){if(((int)a-48)<6) str=strw(get(a+10));
else str=strw(get(a))+strw(219+(((a-48)%8)?0:1));}else if(b-48!= 0){if(((int)b-48)<6)
str=strw(get(b+14))+std::string(((a-38)%10)?(strw(224)+str):"");else{if(((int)b-48)!=8)
str=strw(get(b))+strw(230)+std::string(((a-38)%10)?(strw(224)+str):"");else
str=strw(get(b))+std::string(((a-38)%10)?((strw(236)+strw(224))+str):strw(236));}}
if(c-48!=0) str=strw(get(c))+strw(247)+strw(238)+strw(247)+str;if(str=="")return strw(0);
else return str;}
std::string strw(int n) {
int nn['S'+'T'+'R'] = { 122,101,114,111,123,111,110,101,123,116,
119,111,123,116,104,114,101,101,123,102,111,117,114,123,102,105,
118,101,123,115,105, 120,123,115, 101,118,101,110,123,
101,105,103,104,116, 123,110,105, 110,101,123,116,101,
110,123,101,108, 101,118,101,110,
123,116,119,101, 108,118,101,123,
116,104,105,114, 116,101,101,110,
123,102,111,117,114, 116,101,101, 110,123,102,105,102,
116,101,101,110,123, 116,119,101, 110,116,121,123,116,
104,105,114,116,121, 123,102,111, 114,116,121,123,102,
105,102,116,121,123, 116,104,111, 117,115,197,110,100,
123,109,105,108,108, 105,111,110, 123,198,105,108,108,
105,111,110,123,100, 111,108,108, 197,114,115,123,111,
110,101,132,100, 111,108,108,197,
114,115,123,132, 197,110,100,132,
123,132,199,101, 110,116,115,123,
132,197,110,100,132, 122,101,114, 111,132,199,101,110,
116,115,123,111,110, 101,132,199, 101,110,116,115,123,
145,111,110,101,132,199,101,110,116,115,123,101,101,110,123,116,
101,101,110,123,145,123,116,121,145,123,116,121,123,121,145,123,
121,123,104,117,110,100,114,101,100,123,132,132,123 };
if(nn[n]!='N'*2-'!') return (char)((nn[n]>='{')?nn[n]-'d':nn[n])+strw(n+1);
else return "";
}
int get(char a) {
int n=('n'-'V');
int nn[24] = { 0,5,9,13,19,24,29,33,39,45,50,54,61,68,
77,86,94,101,108,114,119,120,129,137 };
return nn[a-n*2];
}
|