tnfh.net
当前位置:首页 >> JAvA中从键盘下输入任意整数,逆序输出其各位数字 >>

JAvA中从键盘下输入任意整数,逆序输出其各位数字

public static void main(String []args){ Scanner in=new Scanner(System.in); int n=in.nextInt(); while(n!=0){ System.out.print(n%10); n/=10; }}

可以先将输入的10个数字存放到数组中然后遍历输出 public static void main(String[] args) { int[] strs={1,2,3,4,5,6,7,8,9,10};//存放输入数据的数组 //正序输出 for (int i = 0; i < strs.length; i++) { System.out.println(strs[i]); } //...

1、首先输入一正整数 2、可以将这个正整数转化成字符串 3、然后利用字符串的几种方法来将个"正整数"反序输出就行了 public class demo { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.next...

import java.util.Scanner;public class Array {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int [] a = new int[10];int count = 0;System.out.println("请输入10个整数");while (true) {if(scanner.ha...

public static void main(String[] args) { System.out.println("请输入3位的整数"); Scanner in = new Scanner(System.in); int cr = in.nextInt(); int b = cr / 100; int s = cr / 10 %10; int g = cr % 10; System.out.println("倒序:"+g+"...

ya178帮帮团: String inStr=“”; String outStr=""; Scanner in = new Scanner(System.in); while(!inStr.equals("e")){//输入"e"则终止 inStr = in.next(); outStr=inStr+","+outStr; System.out.println(outStr); }

int i = 12343465; int m = 0; while (i != 0) { m =i%10; System.out.print(m); i = i/10; }

import java.util.Scanner; public class test1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a[] = new int [10]; for(int i=0;i=0;j-- ){ System.out.print(a[j]+" "); } } } 这个应该是你要的吧

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); String output = ""+input.charAt(4)+input.charAt(3)+input.charAt(2)+in...

import java.util.*;public class demo {public static void main(String[] args) {Scanner sc = new Scanner(System.in);String line = sc.nextLine();System.out.println(new StringBuilder(line).reverse().toString());}}

网站首页 | 网站地图
All rights reserved Powered by www.tnfh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com