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

来源:互联网 发布:f6 转换为65533 java 编辑:程序博客网 时间:2024/05/21 22:51

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

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

Problem Description

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

Input

输入三个整数。

Output

输出3个整数的最大值。

Example Input

2 8 5

Example Output

8

代码如下: 

#include<iostream>using namespace std;class stu{private:    int a ;    int b ;    int c ;public:    void f()    {        cin >> a >> b >> c ;    }    int max()    {        if(a<b) a=b;        if(a<c) a=c;        return a ;    }}t;int main(){     int max1 ;     t.f() ;     max1 = t.max();     cout << max1 << endl ;     return 0;}


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