圆的比较
来源:互联网 发布:ie修复软件下载 编辑:程序博客网 时间:2024/06/05 02:52
/*烟台大学计算机学院学生*All right reserved.*文件名称:圆的比较*作者:杨飞*完成日期:2014年4月20日*版本号:v1.0*对任务及求解方法的描述部分:圆的比较*我的程序:*/#include <iostream>#include <cmath>using namespace std;class point{protected: double x,y;public: point(double xx,double yy):x(xx),y(yy){} double getx() { return x; } double gety() { return y; } ~point() { } friend ostream& operator <<(istream &putout,point &c);};ostream& operator <<(ostream &putout,point &c){ putout<<"("<<c.getx()<<","<<c.gety()<<")"<<endl; return putout;}class circle:public point{private: double r;public: circle(double xx,double yy,double rr): point(xx,yy),r(rr){} ~circle() { } friend ostream& operator <<(ostream &putout,circle &c); double area() { return 3.14*r*r; } bool operator >=(circle c); bool operator <(circle c); bool operator <=(circle c); bool operator >(circle c); bool operator ==(circle c); bool operator !=(circle c);};ostream& operator <<(ostream &putout,circle &c){ putout<<"("<<c.getx()<<","<<c.gety()<<")"<<endl; putout<<"半径"<<c.r<<endl; return putout;}bool circle::operator >=(circle c){ if(area()>=c.area()) return true; return false;}bool circle::operator <(circle c){ if(*this>=c) return false; return true;}bool circle::operator <=(circle c){ if(area()<=c.area()) return true; return false;}bool circle::operator >(circle c){ if(*this<=c) return false; return true;}bool circle::operator ==(circle c){ if(area()==c.area()) return true; return false;}bool circle::operator !=(circle c){ if(*this==c) return false; return true;}int main( ){ circle c1(3,2,4),c2(4,5,5); //c2应该大于c1 cout<<"圆c1: "<<c1; cout<<"圆c2: "<<c2; cout << "下面比较两个圆的大小:\n"; if (c1 > c2) cout << "c1>c2" << endl; if (c1 < c2) cout << "c1<c2" << endl; if (c1 == c2) cout << "c1=c2" << endl; if (c1 != c2) cout << "c1≠c2" << endl; if (c1>= c2) cout << "c1≥c2" << endl; if (c1 <= c2) cout << "c1≤c2" << endl; return 0;}
运行结果:
心得体会;wu!
0 0
- 圆的比较
- 圆的比较
- 圆的比较
- 13.2圆的比较
- 圆的比较
- 13.2 圆的比较
- 圆的比较
- 圆的比较
- 扩展性比较好的圆角边框
- 第十三周 项目1--圆的比较
- 13【项目2 - 圆的比较】
- 13周 项目2 圆的比较
- 第十三周项目二圆的比较
- 第十三周项目2--圆的比较
- 第十三周项目二圆的比较
- 容器的比较和字符串的比较
- 比较排序的最少比较次数
- EL表达式的比较符号、字符串比较
- Android动画学习笔记
- group_concat()函数总结
- 纪念下。他设计了《青岛谋生记》
- 10款精美而实用的HTML5表单(登录、联系和搜索表单)
- cocos2d 游戏开发实战
- 圆的比较
- Android 开发中的多线程编程技术
- DES 加密解密算法的C++实现
- Mybatis分页插件2.0版本发布
- IllegalStateException: Can not perform this action after onSaveInstanceState
- table自定义排序
- 大数据的数据存储与分析
- Android学习——ClickableSpan点击链接事件 改超链接颜色
- DES加密解密的C++源程序