面向对象程序设计上机练习七(类和对象)

来源:互联网 发布:执行 catmetx.sql脚本 编辑:程序博客网 时间:2024/05/22 08:13

面向对象程序设计上机练习七(类和对象)

Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic

Problem Description

利用类的数据成员和成员函数完成下列操作:输入三个整数,输出它们的最大值。

Input

输入三个整数。

Output

输出3个整数的最大值。

Example Input

2 8 5

Example Output

8

Author

zlh

#include <iostream>#include <algorithm>using namespace std;int cmp(int a, int b)                       //控制排列顺序{    return a < b;}class Num{    private:        int x;        int y;        int z;    public:        void setnum()        {            cin >> x >> y >> z;        }        void findmax()        {            if(x < y)                x = y;            if(x < z)                x = z;        }        void shownum()        {            cout << x << endl;        }};int main(){    Num N;    N.setnum();    N.findmax();    N.shownum();    return 0;}


0 0
原创粉丝点击