码迷,mamicode.com
首页 > 其他好文 > 详细

实验三

时间:2018-04-09 00:32:16      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:cin   AC   double   return   add   .com   end   src   mes   

#include<iostream>

using namespace std;

class rectangle {

public:

 double area(double l,double w);

private:

double length,width;

};

double rectangle::area(double l,double w)

{

length=l;

width=w;

return length*width;

}

int main()

{

rectangle Rectangle;

 double length,width;

cin>>length>>width;

cout<<Rectangle.area(length,width)<<endl;

return 0;

}

技术分享图片

#include<iostream>

using namespace std;

class Complex
{
    public:
    Complex(double r0,double i0){
        real=r0;
        imaginary=i0;
        
    };
    Complex(Complex &c0);
    void add(Complex &C0)
    void show();
    private:
        double real,imaginary;
        
};
void Complex::add(Complex &c0)
{
    real+=c0.real,imaginary+=c0.imaginary;
    
}
void Complex::show()
{
    cout<<real+<<imaginary<<i<<endl;
    
}
int main()
{

Complex c1(3,5);
Complex(4.5);
c1.add(c2);
c2.show();
return 0;
}

技术分享图片

实验三

标签:cin   AC   double   return   add   .com   end   src   mes   

原文地址:https://www.cnblogs.com/baiyixin/p/8747971.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!