首页 > 技术文章 > java输入最大10位数,倒数输出(很鸡肋)

THEONLYLOVE 2018-05-31 14:49 原文

public class D {
public static void main(String[] args) {

System.out.println("请输入数字(最大十位数):");
Scanner sc = new Scanner(System.in);
int sun = sc.nextInt();
System.out.println("已输入:"+sun);
int result = 0;
int i = 0;
while (true){
int n = sun%10;
if (n == -1){
break;
}
i++;
System.out.println("倒数第"+i+"位="+n);
result = result*10+n;
sun = sun/10;

if (sun == 0){
break;
}

}
  }
}

推荐阅读