[2020]:绝对值排序
来源:互联网 发布:pp软件2015下载 编辑:程序博客网 时间:2024/05/21 12:49
绝对值排序
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 56181 Accepted Submission(s): 26995
Problem Description
输入n(n<=100)个整数,按照绝对值从大到小排序后输出。题目保证对于每一个测试实例,所有的数的绝对值都不相等。
Input
输入数据有多组,每组占一行,每行的第一个数字为n,接着是n个整数,n=0表示输入数据的结束,不做处理。
Output
对于每个测试实例,输出排序后的结果,两个数之间用一个空格隔开。每个测试实例占一行。
Sample Input
3 3 -4 2
4 0 1 2 -3
0
Sample Output
-4 3 2
-3 2 1 0
#include<stdio.h>#include<math.h>int main(){ int n, i, j, str[100], temp; while(scanf("%d", &n)!=EOF){ if(n==0){ break; } else{ for(i=0; i<n; i++){ scanf("%d", &str[i]); } for(i=0; i<(n-1); i++){ for(j=i+1; j<n; j++){ if(abs(str[i])<abs(str[j])){ temp = str[i]; str[i] = str[j]; str[j] = temp; } } } for(i=0; i<n; i++){ if(i!=(n-1)){ printf("%d ", str[i]); } else{ printf("%d\n", str[i]); } } } } return 0;}
0 0
- 2020 绝对值排序
- HDU 2020 绝对值排序
- HDU 2020 绝对值排序
- HDU 2020 绝对值排序
- HDU,2020,绝对值排序
- HDU 2020 绝对值排序
- HDU 2020 绝对值排序
- 【2020 绝对值排序 】
- hdu 2020 绝对值排序
- 绝对值排序(2020)
- HDU 2020 绝对值排序
- [hdu 2020] 绝对值排序
- 2020 绝对值排序
- HDUJ 2020 绝对值排序
- hdoj 2020 绝对值排序
- 绝对值排序(2020)
- HDU 2020 绝对值排序
- HDU 2020 绝对值排序
- non-dominated sorting算法的matlab实现
- kkpager-master 这个分页插件的用法
- xcode7.1 cordova 打包的工程 报错 error--> cordova/CDVViewController.h
- [2019]:数列有序
- Leetcode #23 Merge k Sorted Lists
- [2020]:绝对值排序
- 使用mysql yum包安装mysql5.5
- C# 制作软件启动画面
- [IOS]绑定事件时,为何看不到具体的UIControlEvents对象,只有事件委托?
- JS学习笔记(03)——(联动菜单,计时器)
- UIView的Touch事件UIControlEvents详解
- iOS 如何进行逆向工程?
- Xcode 警告信息处理:Format string is not a string literal (potentially insecure)
- Leetcode: Longest Substring with At Most Two Distinct Characters