给定一个五位数,然后把它逆序输出

郑州大学——徐峰

类方法:

public class Homework08 {
void test3 (int a){
int t,i,x=0;
for(i=1;i<=5;i++){
t=a%10;
a=a/10;
x=x*10+t;

}
System.out.print(x);
}
}

 

主方法:

import java.util.Scanner;

public class Main08 {
public static void main(String[] args){
Homework08 z= new Homework08();

Scanner s = new Scanner(System.in);
System.out.println("a=");
int a=s.nextInt();
z.test3(a);
}
}

posted @ 2017-03-26 22:15  我为编程上架构  阅读(1295)  评论(0编辑  收藏  举报