FYCEO 2016-01-06 13:06 采纳率: 100%
浏览 1884
已采纳

在XP系统有完整的内容显示,

一个C++程序能在XP系统完整地显示所有内容,但在WIN8和WIN10不能完整地显示
#include
#include
#include
#define PI 3.1415
using namespace std;
//radius 半径,length 长度 width宽度 heighr 高度

class shape//基类
{
public:
virtual double area()=0;//定义纯虚函数

virtual double volume()=0;//定义纯虚函数
virtual double surface()=0;//定义纯虚函数
virtual double zhouchang()=0;//定义纯虚函数
};
class circle:public shape//圆形
{
protected:
double radius;
public:
circle(double r){radius=r;}
virtual double area(){return PI*radius*radius;}
virtual double zhouchang(){return PI*(radius*2);}
virtual double volume(){return 0;}
virtual double surface(){return 0;}
};
class sphere:public circle//圆球
{
public:
sphere(double r):circle(r){radius=r;}
double volume(){return (4/3)*PI*radius*radius*radius;}
double surface(){return 4*PI*radius*radius;}
};
class cylinder:public circle//圆柱
{
protected:
double height;
public:
cylinder(double r,double h):circle(r){height=h;}
double volume(){return PI*radius*radius*height;}
double surface(){return PI*radius*radius*2+2*radius*PI*height;}
};
class cone:public cylinder//圆锥
{
public:
cone(double r,double h):cylinder(r,h){}
double volume(){return PI*radius*radius*height*(1/3);}
double surface(){return PI*radius*radius+PI*radius*sqrt(radius*radius+height*height);}
};
class Rectangle:public shape//长方形
{
protected:
double length,width;
public:
Rectangle(double l,double w){length=l,width=w;}
double area(){return length*width;}
double zhouchang(){return 2*(length+width);}
virtual double volume(){return 0;}
virtual double surface(){return 0;}
};
class coboid:public Rectangle//长方体
{
protected:
double height;
public:
coboid(double l,double w,double h):Rectangle(l,w){height=h;}
double volume(){return length*width*height;}
double surface(){return length*width*2+length*height*2+width*height*2;}
};
int main()
{
int x;
double r,l,w,h;
shape *shape1 = 0 ;
while(x!=0)
{

    cout<<"设计目标:简单的几何图形周长、面积、体积计算。\n"<<endl;

    cout<<"1.圆形\n"<<endl; 
    cout<<"2.圆球\n"<<endl;
    cout<<"3.圆柱\n"<<endl;
    cout<<"4.圆锥\n"<<endl;
    cout<<"5.长方形\n"<<endl;
    cout<<"6.长方体\n"<<endl;
    cout<<"0.退出\n"<<endl;
    cout<<"请输入编号:";
    cin>>x;
         system("cls");

 switch(x)
 {
  case 1:
    {cout<<"输入圆的半径: ";
    cin>>r;
    circle circle(r);
    shape1 = &circle ;
    cout<<"圆的面积为 :"<<shape1->area()<<endl;
    cout<<"圆的周长为:"<<shape1->zhouchang()<<endl;
    system("pause");
    system("cls") ;
    break;
    }
    case 2:
    {
        cout<<"输入圆球的半径 :";
        cin>>r;
        sphere sphere(r);
        cout<<"圆球的体积为 :"<<sphere.volume()<<endl;
        cout<<"圆球的表面积为 :"<<sphere.surface()<<endl;
        system("pause");
        system("cls") ;
        break;
    }

    case 3:
     {
         cout<<"输入圆柱的半径和高 :\n ";
         cout<<"半径:";cin>>r;
         cout<<"高:";cin>>h;
         cylinder cylinder(r,h);
         cout<<"圆柱的体积为 :"<<cylinder.volume()<<endl;
         cout<<"圆柱的表面积为 :"<<cylinder.surface()<<endl;
         system("pause");
    system("cls") ;
         break;
     }

    case 4:
       {
           cout<<"输入圆锥的半径和高 :\n";
           cout<<"半径:";cin>>r;
           cout<<"高:";cin>>h;
           cone cone(r,h);
           cout<<"圆锥的体积为: "<<cone.volume()<<endl;
           cout<<"圆锥的表面积为 :"<<cone.surface()<<endl;
           system("pause");
    system("cls") ;
           break;
       }

    case 5:
       {
           cout<<"输入长方形的长、宽:\n ";
           cout<<"长:";cin>>l;
           cout<<"宽:";cin>>w;
           Rectangle rectangle(l,w);
           cout<<"长方形的面积为: "<<rectangle.area()<<endl;
           cout<<"长方形的周长为:"<<rectangle.zhouchang()<<endl;
           system("pause");
    system("cls") ;
           break;
       }

     case 6:
       {
           cout<<"输入长方体的长、宽、高: \n";
           cout<<"长:";cin>>l;
           cout<<"宽:";cin>>w;
           cout<<"高:";cin>>h;
           coboid coboid(l,w,h);
           cout<<"长方体的体积为 :"<<coboid.volume()<<endl;
           cout<<"长方体的表面积为: "<<coboid.surface()<<endl;
           system("pause");
    system("cls") ;
           break;
       }
    case 0:
        break; 
}
} 

}
只能显示这些图片说明

  • 写回答

2条回答 默认 最新

  • ysuwood 2016-01-06 13:30
    关注

    看着这么眼熟。
    你编译时的warning错误不看吗?
    warning C4700: 使用了未初始化的局部变量“x”

     int main()
    {
        int x=1;//修改,未初始化
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?