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

来源:互联网 发布:g76螺纹怎么编程 编辑:程序博客网 时间:2024/06/02 21:19

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

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

Problem Description

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

Input

输入三个整数。

Output

输出3个整数的最大值。

Example Input

2 8 5

Example Output

8

Hint

Author

zlh

#include <iostream>using namespace std;class compare{private:    int a[5], i, max;public:    compare()    {        for(i=0; i<3; i++)            a[i] = 0;        max = 0;    };    void newComp();};void compare::newComp(){    for(i=0; i<3; i++)    {        cin >> a[i];    }    max = a[0];    for(i=1; i<3; i++)    {        if(max < a[i])            max = a[i];    }    cout << max;}int main(){    compare T;    T.newComp();    return 0;}


阅读全文
0 0
原创粉丝点击