面向对象程序设计上机练习七(类和对象)
Time Limit: 1000MS
Memory Limit: 65536KB
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;
}