import java.util.Scannerimport java.util.Vector
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner rd = new Scanner(System.in)
int N = 0
// 循环才能输入多组数据
while (rd.hasNextInt()) {
N = rd.nextInt()
if (N == 0) {
break
}
int arr[] = new int[N]
纯闷逗int i, j, temp
for (i = 0i <Ni++) {
arr[i] += rd.nextInt()
}
for (i = 0i <Ni++) {
for (j = N - 1j >ij--) {
//因为你要判断绝对值吗,Math.abs(int a)就是罩冲返回a的绝对值
if (Math.abs(arr[j])>Math.abs(arr[j-1])) {
temp = arr[j - 1]
arr[j - 1] = arr[j]
arr[j] = temp
}
}
}
for (i = 0i <Ni++) {
System.out.print(arr[i] + " ")
}
System.out.println()
}
}}
#include <stdio.h>void main ()
{
int n,i,a[200],j,x,b[200]
scanf("%d",&n)
for(i=0i<ni++)
{ scanf("%d"芦首,&a[i])
if(a[i]<=0)
b[i]=-1*a[i]
else
b[i]=a[i]
}
for(i=0i<n-1i++){
for(j=i+1j<nj++)
if(b[i]>陪银数=b[j])
{
x=b[i]
b[i]=b[j]
b[j]=x
}
}
for(i=0i<ni++)
printf("%d\搏差n",b[i])
}
real :: a(m,n)integer :: xy(2)
xy = minloc( a )
最小辩陵桥值的行号为 xy(1) 列号为 xy(2)
xy = maxloc( a )
最大值的汪薯行号携猛为 xy(1) 列号为 xy(2)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)