题目:绝对值排序
输入 n(n≤100) 个整数,按照绝对值从大到小排序后输出。题目保证所有的数的绝对值都不相等。
输入格式:
第一个数字为 n接着是 n个整数。
输出格式:
输出这 n个整数排序后的结果。
Sample Input
3
3 -4 2
Sample Output
-4 3 2
注意:
其中运用了冒泡排序,abs为绝对值函数(int)
代码如下:
#include<stdio.h>
#include<math.h>
int main()
{
int i,n,a[101];
int j,t;