sdut_java_面向对象程序设计上机练习一(函数重载)
来源:互联网 发布:淘宝店铺标志 编辑:程序博客网 时间:2024/06/06 02:42
面向对象程序设计上机练习一(函数重载)
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
利用数组和函数重载求5个数最大值(分别考虑整数、单精度、长整数的情况)。
Input
分别输入5个int型整数、5个float 型实数、5个long型正整数。
Output
分别输出5个int型整数的最大值、5个float 型实数的最大值、5个long型正整数的最大值。
Example Input
11 22 666 44 5511.11 22.22 33.33 888.88 55.551234567 222222 333333 444444 555555
Example Output
666888.881234567import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner in = new Scanner (System.in);int a = in.nextInt();int a1 = in.nextInt();int a2 = in.nextInt();int a3 = in.nextInt();int a4 = in.nextInt();float f = in.nextFloat();float f1 = in.nextFloat();float f2 = in.nextFloat();float f3 = in.nextFloat();float f4 = in.nextFloat();long l = in.nextLong();long l1 = in.nextLong();long l2 = in.nextLong();long l3 = in.nextLong();long l4 = in.nextLong();Max max = new Max();System.out.println(max.getMax(a, a1, a2, a3, a4));System.out.println(max.getMax(f, f1, f2, f3, f4));System.out.println(max.getMax(l, l1, l2, l3, l4));in.close();}}class Max {int max;float max1;long max2;public Max(){max = 0;max1 = 0;max2 = 0;}public int getMax( int a, int a1, int a2, int a3, int a4 ){max = a;if( a1>max )max = a1;if( a2>max )max = a2;if( a3>max )max = a3;if( a4>max )max = a4;return max;}public float getMax( float a, float a1, float a2, float a3, float a4 ){max1 = a;if( a1>max1 )max1 = a1;if( a2>max1 )max1 = a2;if( a3>max1 )max1 = a3;if( a4>max1 )max1 = a4;return max1;}public long getMax( long a, long a1, long a2, long a3, long a4 ){max2 = a;if( a1>max2 )max2 = a1;if( a2>max2 )max2 = a2;if( a3>max2 )max2 = a3;if( a4>max2 )max2 = a4;return max2;}}
0 0
- sdut_java_面向对象程序设计上机练习一(函数重载)
- sdut 面向对象程序设计上机练习一(函数重载)
- sdut-面向对象程序设计上机练习一(函数重载)
- 【1140】面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- SDUT1140面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- C++ 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 面向对象程序设计上机练习一(函数重载)
- 1140-面向对象程序设计上机练习一(函数重载)
- Android 性能测试工具使用说明
- python hadoop stream 传参
- jQuery中DOM操作方法的简单总结
- Python新手引导 第二篇 你不知道的Python
- 程序员都应该会的抓包工具-Charles
- sdut_java_面向对象程序设计上机练习一(函数重载)
- Python新手引导 第一篇
- Python新手引导 第三篇-Python基础和字符编码
- Python新手引导 第四篇
- 如何破解大型网站的登录
- 将博客搬至CSDN
- 爬虫利器之PhantomJS
- Docker入门
- 汇编语言实验2-汇编语言程序框架