Advertisement
huutho_96

doc so

Mar 24th, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. //https://www.facebook.com/pages/C%C3%B9ng-h%E1%BB%8Dc-l%E1%BA%ADp-tr%C3%ACnh/632038696941833?ref=bookmarks
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. char so[][7] = { " khong", " mot", " hai", " ba", " bon", " nam", " sau", " bay", " tam", " chin" };
  6. char dv[][9] = { " trieu", " nghin", " tram", " muoi", " le"};
  7. void main()
  8. {
  9. long int n = 0, a;
  10. int t = 0;
  11. cout << endl;
  12. cin >> a;
  13. while (a > 0)
  14. {
  15. n = n * 10 + (a % 10);
  16. a = a / 10;
  17. t++;
  18. }
  19. while (n > 0)
  20. {
  21. if (n % 10 != 0 || t % 3 == 0)
  22. {
  23. if (t % 3 == 2 && n % 10 == 1);
  24. else
  25. cout << so[n % 10];
  26. }
  27. if ((t - 1) / 3.0 == 1) cout << dv[1];
  28. if ((t - 1) / 3.0 == 2) cout << dv[0];
  29. if (t % 3 == 0) cout << dv[2];
  30. if (t % 3 == 2)
  31. {
  32. if (n % 10 == 0) cout << dv[4];
  33. else
  34. cout << dv[3];
  35. }
  36. n = n / 10;
  37. t--;
  38. }
  39. if (t > 3 && t < 6) cout << dv[1];
  40. if (t > 6) cout << dv[0];
  41. main();
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement