package Chapter_2;
import java.util.Scanner;
import javax.imageio.stream.ImageInputStream;
import javax.swing.InputVerifier;
public class lianxi2_4 {
public static
void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println("请输入一个0~1000的整数:");
int i=input.nextInt();
while(i<=0||i>=1000)
{
System.out.println("请重新输入:");
i=input.nextInt();
}
System.out.println("各位数之和为:");
System.out.println((i-(i/100)*100)/10+(i/100)+i%10);
}
}
求0~1000的整数各位数之和
最新推荐文章于 2022-05-14 13:56:36 发布