================================
package HspLearning;
public class For3 {
public static void main(String[] args) {
int start = 1;
int end = 100;
int count = 0;
int sum = 0;
for (int i = start;i<= end;i++){
if(i%9 == 0){
System.out.println("i="+i);
count++;
sum +=i;
}
}
System.out.println("能被9整除的个数为:"+count);
System.out.println(sum);
}
}
===========
image.png
===========
package HspLearning;
public class For3 {
public static void main(String[] args) {
int start = 1;
int end = 100;
int t = 9;
int count = 0;
int sum = 0;
for (int i = start;i<= end;i++){
if(i % t == 0){
System.out.println("i="+i);
count++;
sum +=i;
}
}
System.out.println("能被9整除的个数为:"+count);
System.out.println(sum);
}
}
网友评论