| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 497 人关注过本帖
标题:不可以实现double的运算
只看楼主 加入收藏
面朝大海1994
Rank: 2
等 级:论坛游民
威 望:1
帖 子:27
专家分:38
注 册:2012-12-31
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
不可以实现double的运算
#include<iostream>
#include<cmath>
using namespace std;
class Rectangle
{
 private:
 double  left;
 double  bottom;
 double  right;
 double  top;
public:
 void SetPoint(double l,double b,double  r,double  t)
 {
  left=l;
  bottom=b;
  right=r;
  top=t;
 }
 void cal(double  left,double  bottom,double  right,double top)
 {
  double s,m;
  s=abs(left-right)*abs(bottom-top);
  m=(abs(left-right)+abs(bottom-top))*2.0;

  cout<<"该长方形的面积为:"<<s<<endl;
  cout<<"该长方形的周长为:"<<m<<endl;
 }
 void Getp1(double  left,double bottom)
 {
  cout<<"长方形的左下角坐标是:"<<left<<","<<bottom<<endl;
 }
 void Getp2(double right, double top)
 {
  cout<<"长方形的右上角坐标是:"<<right<<","<<top<<endl;
 }
};
 
void main()
{  
 Rectangle r1;
 double  l,b,r,t;
 cout<<"请输入长方形的左下角的坐标:";
 cin>>l>>b;
 cout<<"请输入长方形的右上角的坐标:";
 cin>>r>>t;
 r1.Getp1(l,b);
 r1.Getp2(r,t);
 r1.cal(l,b,r,t);
}

[ 本帖最后由 面朝大海1994 于 2013-5-10 17:02 编辑 ]
搜索更多相关主题的帖子: private include double public bottom 
2013-05-10 10:51
Pirelo
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:118
专家分:550
注 册:2011-1-28
收藏
得分:14 
回复 楼主 面朝大海1994
没搞懂楼主的问题是什么,class的数据成员是double,问的却是不可以实现float的运算?
2013-05-10 13:06
面朝大海1994
Rank: 2
等 级:论坛游民
威 望:1
帖 子:27
专家分:38
注 册:2012-12-31
收藏
得分:0 
回复 2楼 Pirelo
不可以实现double的功能,呵呵!

吃得苦中苦,方为人上人!
2013-05-10 17:02
快速回复:不可以实现double的运算
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019067 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved