求高人帮忙编写一C程序,具体如下

来源:百度知道 编辑:UC知道 时间:2024/05/31 11:25:04
完成如下功能:输入中文表示的钱的多少,用数字显示出来。例如:一块八、一元八角、一块八毛均表示为1.8
感谢楼下的回答,但是还是有些语法错误。。。。

赶紧给我多加分!!!

#include <iostream.h>
#include <string.h>
typedef char* string;
class CMoney
{
public:
CMoney(double a = 0.0) { amount = a; }
operator string ();
private:
double amount;
};
CMoney::operator string ()
{
string basestr[15] = {"分", "角", "元", "拾", "佰", "仟", "万",
"拾", "佰", "仟", "亿",
"拾", "佰", "仟", "万"};
string datastr[10] = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
static char strResult[80];
double temp, base = 1.0;
int n = 0;
temp = amount * 100.0;
strcpy(strResult, "金额为: ");
if (temp < 1.0) strcpy (strResult, "金额为: 零元零角零分");
else
{<