1. 程式人生 > >SDUT- 1140 面向物件程式設計上機練習一(函式過載)

SDUT- 1140 面向物件程式設計上機練習一(函式過載)

import java.util.Scanner;

public class Main {
	static int Max(int a[])
	{
		int ans = a[0];
		for(int i = 0; i < 5; i++)if(a[i] > ans)ans = a[i];
		System.out.println(ans);
		return ans;
	}
	static float Max(float a[])
	{
		float ans = a[0];
		for(int i = 0; i < 5; i++)if(a[i] > ans)ans = a[i];
		System.out.println(ans);
		return ans;
	}
	static long Max(long a[])
	{
		long ans = a[0];
		for(int i = 0; i < 5; i++)if(a[i] > ans)ans = a[i];
		System.out.println(ans);
		return ans;
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int a[] = new int [5];
		float b[] = new float[5];
		long c[] = new long[5];
		int i;
		for(i = 0; i < 5; i++)a[i] = cin.nextInt();
		for(i = 0; i < 5; i++)b[i] = cin.nextFloat();
		for(i = 0; i < 5; i++)c[i] = cin.nextLong();
		Max(a);
		Max(b);
		Max(c);
		cin.close();
	}
}