分析
考虑使用for循环对1~100之间的数进行排查。
实战
public static void main(String[] args)
{
int i, count = 0, temp = 0;
for (i = 1; i <= 100; i++)
{
if (i % 9 == 0)
{
temp += i;
count++;
}
}
System.out.println("1~100之间为9的倍数的整数个数为:" + count + ",总和为:" + temp);
}
结果

PS: 每天坚持撸代码,总有一天会秃的