64,654
社区成员
发帖
与我相关
我的任务
分享
2>重新:#include <iostream>
#include <stdlib.h>
using namespace std;
class building
{
public:
building(int f = 0, int h = 0, long s = 0)
{
fr = f;
r = h;
m = s;
}
virtual ~building(){}
int getf()
{
cout<<"楼层数:"<<fr<<endl;
}
int geth()
{
cout<<"房间数:"<<r<<endl;
}
int gets()
{
cout<<"面积数:"<<m<<endl;
}
private:
int fr;
int r;
long m;
};
class house:public building
{
public:
house(int f = 0, int h = 0, long s = 0, int b = 0, int d = 0):building(f,h,s)
{
br = b;
dr = d;
}
~house(){}
int getb()
{
cout<<"卧室数:"<<br<<endl;
}
int getd()
{
cout<<"浴室数:"<<dr<<endl;
}
private:
int br;
int dr;
};
int main()
{
house obj(10,200,30000,500,300);
obj.getf();
obj.geth();
obj.gets();
obj.getb();
obj.getd();
system("PAUSE");
return 1;
}
#include <iostream>
#include <math.h>
int main(int argc, char * argv[])
{
int a,b;
std::cin>>a>>b;
std::cout<<((a+b)-abs(a-b))/2<<" "<<((a+b)+abs(a-b))/2<<std::endl;
return 0;
}
class building
{
private:
int fr;
int r;
float m;
public:
building(int fr_c=0,int r_c=0,float m_c=0):fr(fr_c),r(r_c),m(m_c){};
int get_fr(){return fr;}
//.....
};
class house: public building
{
private:
int br;
int dr;
public:
house(int fr_c=0,int r_c=0,float m_c=0,int br_c=0,int dr_c=0):building(fr_c,r_c,m_c),br(br_c),dr(dr_c){};
int get_br(){return br;}
int get_dr(){return dr;}
};
int main()
{
house h(100,200,30000,500,300);
cout<<h.get_br()<<endl;
cout<<h.get_fr()<<endl;
//....
return 0;
}
#include <iostream>
using namespace std;
class building
{
private:
int fr;
int r;
float m;
public:
building ( )
{
fr = r = 0;
m = 0.0;
}
building (int f, int r1, float m1) : fr(f), r(r1), m(m1){ }
friend ostream & operator << (ostream & os, building & b)
{
os<<b.fr<<' '<<b.r<<' '<<b.m<<endl;
return os;
}
};
class house : public building
{
private:
int num_ws; //卧室数
int num_ys; //浴室数
public:
house ( )
{
num_ws = 0;
num_ys = 0;
}
house (int f, int r1, float m1, int n_w, int n_y) : building (f, r1, m1 ), num_ws(n_w), num_ys(n_y) { }
friend ostream & operator << (ostream & os, house &h)
{
os<<building(h);
os<<h.num_ws<<' '<<h.num_ys<<endl;
return os;
};
};
int main ( )
{
house h(10, 200, 30000.0, 500, 300);
cout<<h<<endl;
return 0;
}
#include <iostream.h>
void main()
{
int a,b;
if(a<b)
{
cout<<a<<b<<endl;
}
else if(a>b)
{
cout<<b<<a<<endl;
}
}
int main()
{
int a,b,cmp;
cin>>a>>b;
if(a>b)
{
cmp=a;
a=b;
b=cmp;
}
cout<<a<<" "<<b<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a>b)
{
cout<<a<<b<<endl;
}
else
cout<<b<<a<<endl;
return 0;
}
#include <iostream>
int main()
{
int a,b;
cin>>a>>b;
if(a>b)
{
cout<<a<<b<<endl;
}
else
cout<<b<<a<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main ( )
{
int a,b;
cout<<"输入两个整数:"<<endl;
cin>>a>>b;
if (a>b)
cout<<a<<' '<<b<<endl;
else
cout<<b<<' '<<a<<endl;
return 0;
}