求绝对值最大值
来源:互联网 发布:人工智能代替老师 编辑:程序博客网 时间:2024/06/06 09:44
求绝对值最大值
Problem Description
求n个整数中的绝对值最大的数。
Input
输入数据有2行,第一行为n,第二行是n个整数。
Output
输出n个整数中绝对值最大的数。
Example Input
5-1 2 3 4 -5
Example Output
-5
代码:
#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){ int i, n, a, fa, max, maxold; scanf("%d", &n); scanf("%d", &a); max = ((a >= 0)? a : -a); maxold = a; for(i = 1; i < n; i++) { scanf("%d", &a); fa = a; if(a < 0) { fa = -a; } if(max < fa) { max = fa; maxold = a; } } printf("%d\n", maxold); return 0;}
阅读全文
0 0
- 求绝对值最大值
- 求绝对值最大值
- 求绝对值最大值
- 求绝对值最大值
- 求绝对值最大值
- 求绝对值最大值
- 求绝对值最大值
- 求绝对值最大值 (sdut oj)
- SDUT-1147 求绝对值最大值
- 山东理工ACM【1147】求绝对值最大值
- 二叉树遍历求差值绝对值最大值
- 求数组左部分最大值减去右部分最大值的绝对值的最大值
- 求绝对值
- 求绝对值
- 求绝对值
- 求绝对值
- 求绝对值
- 求绝对值
- 【BZOJ3669】【Noi2014】魔法森林(Link-Cut Tree)
- Django网站框架的使用(一)
- C\C++语言指针的强大用法之数组当作指针使用
- YOLO_GPU+cuda7.5+cv2.4.10实现
- MWeb + 七牛发布 Markdown文章
- 求绝对值最大值
- 算法:冒泡排序
- Shell脚本基础
- HTML的01
- 关于text文本插入多条数据
- 算法_01_Manacher
- SSH远程登陆用法及原理
- openssl gmssl x509 证书
- 黑客内参-使用恶意软件将隐藏代码注入已知进程的渗透研究