
求C++编程高手帮忙做几个题。
1.写一个程序:输入字符串的数字,转换成数字输出屏幕2.写一个程序:输入二进制,输入8进制,输入16进制数,转换成10进制数输出3.用操作符重载,写一个NUMBER类,实...
1.写一个程序:输入字符串的数字,转换成数字输出屏幕
2.写一个程序:输入二进制,输入8进制,输入16进制数,转换成10进制数输出
3.用操作符重载,写一个NUMBER类,实现四则运算
4.写INTARRAY,浅拷贝和深度拷贝
5.STRING类
6.写一个SHAPE类,实现继承和多态 展开
2.写一个程序:输入二进制,输入8进制,输入16进制数,转换成10进制数输出
3.用操作符重载,写一个NUMBER类,实现四则运算
4.写INTARRAY,浅拷贝和深度拷贝
5.STRING类
6.写一个SHAPE类,实现继承和多态 展开
3个回答
2013-07-19
展开全部
第6个问题,我把我上学期作的实验给你吧:
#include <iostream.h>
class Shape
{
protected:
double radius;
public:
Shape(double r)
{
radius=r;
}
virtual double area()=0;
virtual double volume()=0;
virtual void print()=0;
};
class Cube:public Shape
{
public:
Cube(double r):Shape(r)
{
}
double area()
{
return (6*radius*radius);
}
double volume()
{
return (radius*radius*radius);
}
void print()
{
cout<<"Cube area is: "<<this->area()<<endl;
cout<<"Cube volume is: "<<this->volume()<<endl;
}
};
class Sphere:public Shape
{
public:
Sphere(double r):Shape(r)
{
}
double area()
{
return (4*3.14*radius*radius);
}
double volume()
{
return (4*3.14*radius*radius*radius/3);
}
void print()
{
cout<<"Sphere area is: "<<this->area()<<endl;
cout<<"Sphere volume is: "<<this->volume()<<endl;
}
};
class Cylinder:public Shape
{
protected:
double height;
public:
Cylinder(double r,double h):Shape(r)
{height=h;}
double area()
{
return (height*2*3.14*radius+2*3.14*radius*radius);
}
double volume()
{
return (2*3.14*radius*radius*height);
}
void print()
{
cout<<"Cylinder area is: "<<this->area()<<endl;
cout<<"Cylinder volume is: "<<this->volume()<<endl;
}
};
Main函数自己写吧,我调试过,是对的,放心^_^
#include <iostream.h>
class Shape
{
protected:
double radius;
public:
Shape(double r)
{
radius=r;
}
virtual double area()=0;
virtual double volume()=0;
virtual void print()=0;
};
class Cube:public Shape
{
public:
Cube(double r):Shape(r)
{
}
double area()
{
return (6*radius*radius);
}
double volume()
{
return (radius*radius*radius);
}
void print()
{
cout<<"Cube area is: "<<this->area()<<endl;
cout<<"Cube volume is: "<<this->volume()<<endl;
}
};
class Sphere:public Shape
{
public:
Sphere(double r):Shape(r)
{
}
double area()
{
return (4*3.14*radius*radius);
}
double volume()
{
return (4*3.14*radius*radius*radius/3);
}
void print()
{
cout<<"Sphere area is: "<<this->area()<<endl;
cout<<"Sphere volume is: "<<this->volume()<<endl;
}
};
class Cylinder:public Shape
{
protected:
double height;
public:
Cylinder(double r,double h):Shape(r)
{height=h;}
double area()
{
return (height*2*3.14*radius+2*3.14*radius*radius);
}
double volume()
{
return (2*3.14*radius*radius*height);
}
void print()
{
cout<<"Cylinder area is: "<<this->area()<<endl;
cout<<"Cylinder volume is: "<<this->volume()<<endl;
}
};
Main函数自己写吧,我调试过,是对的,放心^_^
2013-07-19
展开全部
1,
#include<iostream.h>
void main()
{ char *a,i;
int b;
gets(a);
for(i=0;i<strlen(a);i++)
{
b=*(a+i)-48;
printf("%d ",b);
}
}
2.
#include<iostream.h>
void main()
{ char *a,i;
int b;
gets(a);
for(i=0;i<strlen(a);i++)
{
b=*(a+i)-48;
printf("%d ",b);
}
}
2.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-19
展开全部
啥意思....
你啥时候开始研究这个勒...
你啥时候开始研究这个勒...
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询