Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4. using namespace std;
  5. int main()
  6. {
  7. string input;
  8. while(cin>>input)
  9. {
  10. int ans[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  11. int a,k=0,check=0,n;
  12. string str="壹";
  13. a=input.size();
  14. n=str.size();
  15. int len=a/2;
  16. string temp[100];
  17. for (int i = 0 ,j=0; i < a ; i+=n,j++)
  18. {
  19. temp[j] = input.substr(i,n);
  20. temp[j]+="\0";
  21. }
  22. for(int i=len;i>=0;i--)
  23. {
  24. if(temp[i]=="負")
  25. cout<<"-";
  26.  
  27. else if(temp[i]=="壹")
  28. ans[k]=1;
  29.  
  30. else if(temp[i]=="貳")
  31. ans[k]=2;
  32.  
  33. else if(temp[i]=="參")
  34. ans[k]=3;
  35.  
  36. else if(temp[i]=="肆")
  37. ans[k]=4;
  38.  
  39. else if(temp[i]=="伍")
  40. ans[k]=5;
  41.  
  42. else if(temp[i]=="陸")
  43. ans[k]=6;
  44.  
  45. else if(temp[i]=="柒")
  46. ans[k]=7;
  47.  
  48. else if(temp[i]=="捌")
  49. ans[k]=8;
  50.  
  51. else if(temp[i]=="玖")
  52. ans[k]=9;
  53.  
  54. else if(temp[i]=="拾")
  55. k=check+1;
  56.  
  57. else if(temp[i]=="佰")
  58. k=check+2;
  59.  
  60. else if(temp[i]=="仟")
  61. k=check+3;
  62.  
  63. else if(temp[i]=="萬")
  64. {
  65. check=4;
  66. k=4;
  67. }
  68. else if(temp[i]=="億")
  69. {
  70. check=8;
  71. k=8;
  72. }
  73.  
  74. }
  75. for(int i=k;i>=0;i--)
  76. {
  77. cout<<ans[i];
  78. if(i%3==0&&i!=0)
  79. cout<<",";
  80. }
  81. cout<<endl;
  82. }
  83.  
  84.  
  85.  
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement