题1;
public class Demo1 {
public static void main(String[] args) {
int i = 1;
int sum = 0;
while (i<=100){
sum+=i;
i++;
}
System.out.println(sum);
}
}
题2;
public class Demo2 {
public static void main(String[] args) {
int i = 1;
int sum = 0;
while (i<=100){
if (i % 2 != 0)
sum+=i;
i++;
}
System.out.println(sum);
}
}
题3;
public class Demo3 {
public static void main(String[] args) {
int i = 1;
int sum = 0;
while (i<=100){
if (i%2 ==0)
sum+=i;
i++;
}
System.out.println(sum);
}
}
题4;
public class Demo4 {
public static void main(String[] args) {
int i =1;
int sum = 0;
while (i<=100){
if (i%10==0)
sum+=i;
i++;
}
System.out.println(sum);
}
}
题5;
public class Demo5 {
public static void main(String[] args) {
int i = 1;
int sum = 0;
int sym = 0;
int cha = 0;
while (i<=100){
if (i%2 ==0)
sum+=i;
if(i%2!=0)
sym+=i;
i++;
}
cha=sym-sum;
System.out.println(cha);
}
}
题6;
public class Demo6 {
public static void main(String[] args) {
int i =1;
int sum = 0 ;
while (i<=100){
if(i%5==0)
sum+=1;
i++;
}
System.out.println(sum);
}
}
题7;
public class Demo7 {
public static void main(String[] args) {
int i = 1;
int sum = 0;
while (i<=100){
if (i%2 ==0)
sum+=1;
i++;
}
System.out.println(sum);
}
}
题8;
public class Demo8 {
public static void main(String[] args) {
int i =1;
int fsz=0;
int osz=0;
int sum=0;
while (i<=100){
if (i%5==0)
fsz+=i;
if(i%4==0)
osz+=i;
i++;
sum=fsz+osz;
}
System.out.println(sum);
}
}
题9;
public class Demo9 {
public static void main(String[] args) {
int i = 1;
int tfs = 1;
while (i<=100){
if (i % 2 != 0&&i%3==0)
tfs=i;
}
i++;
System.out.println(tfs);
}
}
}
题10;
public class Demo10 {
public static void main(String[] args) {
int i = 1;
int tfs = 0;
while (i <= 100) {
if (i % 2 == 0&&i % 8 == 0) {
tfs +=1;
}
i++;
}
System.out.println(tfs);
}
}