java代码逆序输出再连篇

总结:思维方式关键

package com.dfd;

import java.util.Scanner;

//逆序输出数字
public class fdad {
	public static void main(String[] args) {
		int y;
		Scanner c = new Scanner(System.in);
		System.out.println("请输入----");
		int x = c.nextInt();

		System.out.print("输出后的数为:");// 这一步可以省,只是不会显示"输出后的数为:"
		// int y = 0;
		while (x > 0) {
			y = x % 10;
			System.out.print("" + y);// 这一步必须有,不能省,否则无法显示输出,代码精简,绝不失误
			x = x / 10;
		}
	}
}
//
请输入----
34654
45643

  

原文地址:https://www.cnblogs.com/langlove/p/3409728.html