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

来源:互联网 发布:乐知在线英语免费 编辑:程序博客网 时间:2024/05/22 06:55

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

Time Limit: 1000MS Memory Limit: 65536KB
SubmitStatistic

Problem Description

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

Input

输入三个整数。

Output

输出3个整数的最大值。

Example Input

2 8 5

Example Output

8
#include <iostream>
#include <cstdio>
using namespace std;
class Time{
private:
int a[6];
int t;
public:
void input()
{
for(int i=0;i<3;i++)
cin>>a[i];
}
void Max()
{
for(int i=0;i<2;i++)
for(int j=0;j<2-i;j++)
{
if(a[j]<a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
void show()
{
cout<<a[0]<<endl;
}
};
int main()
{
Time t;
t.input();
t.Max();
t.show();
return 0;
}

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