java 逆序输出整数

2024-12-26 04:18:46
推荐回答(1个)
回答1:

public static void main(String[] args){
int ri, repeat;
int number, sum,n;
Scanner in=new Scanner(System.in);
repeat=in.nextInt();
for(ri=1; ri<=repeat; ri++){
n=in.nextInt();
/*--------------------*///此处填空
number = String.valueOf(n).length();
sum = 0;
while(n/10 != 0){
sum += n%10;
n = n/10;
if(n/10 ==0){
sum += n;
}

}
System.out.println("number="+number+", sum="+sum);
}
}

自己看看吧。。