import java.util.Scanner;
public class Demo11 {
public static void main(String[] args) {
int i=0,s=0;
while (i<=100){
s+=i;
i++;
}
System.out.println(s);
}
}
public class Demo12 {
public static void main(String[] args) {
int i = 0, s = 0;
while (i <= 100) {
if (i % 2 == 0) {
s += i;
i++;
} else {
i++;
continue;
}
}
System.out.println(s);
}
}
public class Demo13 {
public static void main(String[] args) {
int i = 0, s = 0;
while (i <= 100) {
if (i % 2 != 0) {
s += i;
i++;
} else {
i++;
continue;
}
}
System.out.println(s);
}
}
public class Demo14 {
public static void main(String[] args) {
int i = 1;
while (i <= 100) {
if (i % 10 == 0) {
System.out.println(i);
i++;
} else {
i++;
}
}
}
}
public class Demo15 {
public static void main(String[] args) {
int i = 0, s = 0, h = 0;
while (i <= 100) {
if (i % 2 != 0) {
s += i;
i++;
} else {
i++;
continue;
}
}
i = 1;
while (i <= 100) {
if (i % 2 == 0) {
h += i;
i++;
} else {
i++;
continue;
}
}
System.out.println(h-s);
}
}
public class Demo16 {
public static void main(String[] args) {
int i = 1,a=0;
while (i <= 100) {
if (i % 5 == 0) {
a++;
i++;
} else {
i++;
continue;
}
}System.out.println(a);
}
}
public class Demo17 {
public static void main(String[] args) {
int i = 0,a=0;
while (i <= 100) {
if (i % 2 == 0) {
a++;
i++;
} else {
i++;
continue;
}
}System.out.println(a);
}
}
public class Demo18 {
public static void main(String[] args) {
int i = 1;
while (i <= 100) {
if (i % 5 == 0 & i % 4 == 0) {
System.out.println(i);
i++;
} else {
i++;
}
}
}
}
public class Demo19 {
public static void main(String[] args) {
int i = 1;
while (i <= 100) {
if (i % 2 != 0 & i % 3 == 0) {
System.out.println(i);
i++;
} else {
i++;
}
}
}
}
public class Demo20 {
public static void main(String[] args) {
int i = 0,s=0;
while (i <= 100) {
if (i % 2 == 0 & i % 8 == 0) {
s++;
i++;
} else {
i++;
}
}
System.out.println(s);
}
}
java练习题-day02
最新推荐文章于 2024-10-31 15:56:11 发布