C++BUILDER使用FASTRESPORT大写金额的问题
请问FASTRESPORT如何将合计金额转为中文大写,网上有很多代码,都是PASCAL的,但是这些代码应该放在那里,网上只提供了函数,但是具体位置应该放在那里?是否FASTRESPORT可以自定义函数?另外一个问题是C++BUILDER能否使用这些函数?
[解决办法]
17.string convertNum(int num)
18.{
19. static const string letter[] = {"零","一","二","三","四","五","六","七","八","九"};
20. static const string unit[] = {"","十","百","千","万","十","百","千","亿","十"};
21. string src;
22. string des;
23. char tmp[12];
24. sprintf(tmp, "%d", num);
25. src.append(tmp);
26.
27. if ( num < 0 )
28. {
29. des.append("负");
30. src.erase(0, 1);
31. }
32.
33. int len = src.length();
34. bool bPreZero = false;
35. for ( int i = 0; i < len; i++)
36. {
37. int digit = src.at(i) - '0';
38. int unit_index = len - i - 1;
39. if (i == 0 && digit == 1 && (unit_index == 1
[解决办法]
unit_index == 5
[解决办法]
unit_index == 9))
40. {
41. des.append(unit[unit_index]);
42. }
43. else if ( digit == 0 )
44. {
45. bPreZero = true;
46. if (unit_index == 4
[解决办法]
47. unit_index == 8)
48. {
49. des.append(unit[unit_index]);
50. }
51. }
52. else
53. {
54. if ( bPreZero )
55. {
56. des.append(letter[0]);
57. }
58. des.append(letter[digit]);
59. des.append(unit[unit_index]);
60. bPreZero = false;
61. }
62. }
63. return des;
64.}
65.