当前位置: 代码迷 >> J2SE >> 基础题(小程序)解决办法
  详细解决方案

基础题(小程序)解决办法

热度:8123   发布时间:2013-02-25 00:00:00.0
基础题(小程序)
一串数字,如何颠倒过来,如:32456变成65423,求指点

------解决方案--------------------------------------------------------
Java code
import java.util.Scanner;public class Reverse{      public static void main(String[] args)    {        Scanner sc=new Scanner(System.in);        System.out.println("pLease in put a number:");        int number=sc.nextInt();        StringBuffer sb=new StringBuffer(""+number);        sb.reverse();        System.out.println(sb.toString());    }}
------解决方案--------------------------------------------------------
int a[] = {3,2,4,5,6};
int b[] = new b[5];
for(int i=0;i<a.length;i++){

b[i] = a[a.length-1]; 
}

这样应该就可以了
  相关解决方案