java怎样生成50-100的随机数整数包括50 100

2024-12-18 00:52:09
推荐回答(1个)
回答1:

importjava.util.*;
public class lianxi24 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("请输入一个正整数:");
long a = s.nextLong();
String ss = Long.toString(a);
char[] ch = ss.toCharArray();
int j=ch.length;
System.out.println(a + "是一个"+ j +"位数。");
System.out.print("按逆序输出是:");
for(int i=j-1; i>=0; i--) {
System.out.print(ch[i]);
}
}
}