求绝对值最大值
- 求绝对值最大值 推荐度:
- 相关推荐
求绝对值最大值
Problem Description
求n个整数中的绝对值最大的数。
Input
输入数据有2行,第一行为n,第二行是n个整数。
Output
输出n个整数中绝对值最大的数。
Sample Input
5 -1 2 3 4 -5
Sample Output
-5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a = input.nextInt();
int i;
int h[]=new int[a];
for(i=0;i<a;i++)
{
h[i] = input.nextInt();
}
int f = h[0];
for(i=0;i<a;i++)
{
if(Math.abs(h[i])>Math.abs(f))f=h[i];
}
System.out.println(f);
input.close();
}
}
最新文章
- linux的s权限和t权限
- 《C语言程序教程》课后编程题
- java tooltip
- linux下 mysql的重启,启动,停止命令
- Cygwin、Msys、MinGW、Msys2的区别与联系
- java文件下载错误提示
- 漫谈系列—大数定律
- gallery3D(3)
- mmap如何使用?
- Android: How to Capture Screen in Gingerbread(2.3中实现截屏)
- Linux下网络流量实时监控
- Hashtable和Hashset
- pgpool分析二
- 线性内插interp1函数用法
- Python的return语句中使用条件判断
- 【机器学习数据集】如何获得机器学习的练习数据?
- 第九届 蓝桥杯 决赛 交换次数