Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main()
- {
- string input;
- while(cin>>input)
- {
- int ans[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- int a,k=0,check=0,n;
- string str="壹";
- a=input.size();
- n=str.size();
- int len=a/2;
- string temp[100];
- for (int i = 0 ,j=0; i < a ; i+=n,j++)
- {
- temp[j] = input.substr(i,n);
- temp[j]+="\0";
- }
- for(int i=len;i>=0;i--)
- {
- if(temp[i]=="負")
- cout<<"-";
- else if(temp[i]=="壹")
- ans[k]=1;
- else if(temp[i]=="貳")
- ans[k]=2;
- else if(temp[i]=="參")
- ans[k]=3;
- else if(temp[i]=="肆")
- ans[k]=4;
- else if(temp[i]=="伍")
- ans[k]=5;
- else if(temp[i]=="陸")
- ans[k]=6;
- else if(temp[i]=="柒")
- ans[k]=7;
- else if(temp[i]=="捌")
- ans[k]=8;
- else if(temp[i]=="玖")
- ans[k]=9;
- else if(temp[i]=="拾")
- k=check+1;
- else if(temp[i]=="佰")
- k=check+2;
- else if(temp[i]=="仟")
- k=check+3;
- else if(temp[i]=="萬")
- {
- check=4;
- k=4;
- }
- else if(temp[i]=="億")
- {
- check=8;
- k=8;
- }
- }
- for(int i=k;i>=0;i--)
- {
- cout<<ans[i];
- if(i%3==0&&i!=0)
- cout<<",";
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement