程序为什么结果不正确,运行结果出问题了,正确答案是一个是9000和9450

[复制链接]
查看11 | 回复1 | 2011-6-27 02:11:01 | 显示全部楼层 |阅读模式
#includeiostream
usingnamespacestd;
classBox
{
public:
        Box(int,int,int);
        intvolume();
private:
        intheight;
        intwidth;
        intlength;
};


Box::Box(inth,intw,intl)
{
        height=h;
        width=w;
        length=l;

}


intBox::volume()
{
        intmid;
        mid=length*width*length;
        returnmid;
}

intmain()
{
Boxbox1(12,25,30);
        cout\"盒子1的体积是:\"box1.volume()endl;
        Boxbox2(15,30,21);
        cout\"盒子2的体积是:\"box2.volume()endl;
        return0;

}
回复

使用道具 举报

千问 | 2011-6-27 02:11:01 | 显示全部楼层
同学你的volume函数写错了应该是mid=length*width*height;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行