public static void main(String[] args) {
int sum = 0;
int count = 0;
System.out.println("1-100之间不能被7整除的数为:");
for (int i = 1; i < 101; i++) {
if( i % 7 != 0){
sum += i ;
count ++;
System.out.print(i+"\t");
if(count == 4){
System.out.println();
count = 0;
}
}
}
System.out.println("\n数据之和为:"+sum);
}
public class Test3 {
public static void main(String[] args){
int num=0;
for (int i = 1; i <= 100; i++) {
if(i%7!=0){
System.out.println(i);
num+=i;
}
}
System.out.println(num);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int sum=0;
int a=0; //能被7整除的数字个数;
System.out.println("1~100中所有不能被7整除的数为:");
for(int i=1;i<=100;i++) {
if(i%7!=0) {
sum=sum+i;
a++;
System.out.print(i+"\t");
}
if(a==4) {
a=a-4;
System.out.println();
}
}
System.out.println("数据之和为:"+sum);
}
}