码迷,mamicode.com
首页 > 其他好文 > 详细

逆序排列

时间:2016-01-19 14:06:06      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:

/**
例子输入
7 19 -5 6 2 0
例子输出
2 6 -5 19 7
 */
import java.util.*;
import java.io.*;
public class 逆序排列 {


public static void main(String[] args) {
Scanner in=new Scanner(new BufferedInputStream(System.in));
int [] a=new int [21];
int num=0;
a[0]=in.nextInt();
for(int i=1;i<a.length;i++){
if(a[0]!=0){
a[i]=in.nextInt();
num++;
}
if(a[i]==0)
break;
}
for(int i=num-1;i>=0;i--){
if(i!=0)
System.out.print(a[i]+" ");
else
System.out.println(a[i]);
}
}
}

逆序排列

标签:

原文地址:http://www.cnblogs.com/gcczhongduan/p/5141838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!