Problem Description
利用数组和函数重载求5个数最大值(分别考虑整数、单精度、长整数的情况)。
Input
分别输入5个int型整数、5个float 型实数、5个long型正整数。
Output
分别输出5个int型整数的最大值、5个float 型实数的最大值、5个long型正整数的最大值。
Example Input
11 22 666 44 55 11.11 22.22 33.33 888.88 55.55 1234567 222222 333333 444444 555555
Example Output
666 888.88 1234567
Hint
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a,b,c,d,e;
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
d = in.nextInt();
e = in.nextInt();
float a1,b1,c1,d1,e1;
a1 = in.nextFloat();
b1 = in.nextFloat();
c1 = in.nextFloat();
d1 = in.nextFloat();
e1 = in.nextFloat();
long a2,b2,c2,d2,e2;
a2 = in.nextLong();
b2 = in.nextLong();
c2 = in.nextLong();
d2 = in.nextLong();
e2 = in.nextLong();
Max max = new Max();
System.out.println(max.getmax(a, b, c, d, e));
System.out.println(max.getmax(a1, b1, c1, d1, e1));
System.out.println(max.getmax(a2, b2, c2, d2, e2));
in.close();
}
}
class Max{
int a,b,c,d,e;
public Max(){
a = 0;
b = 0;
c = 0;
d = 0;
e = 0;
}
public int getmax(int a,int b,int c,int d,int e){
int f = a;
if(b>f)
f=b;
if(c>f)
f=c;
if(d>f)
f=d;
if(e>f)
f=e;
return f;
}
public float getmax(float a,float b,float c,float d,float e){
float f = a;
if(b>f)
f=b;
if(c>f)
f=c;
if(d>f)
f=d;
if(e>f)
f=e;
return f;
}
public long getmax(long a,long b,long c,long d,long e){
long f = a;
if(b>f)
f=b;
if(c>f)
f=c;
if(d>f)
f=d;
if(e>f)
f=e;
return f;
}
}