import java.sql.SQLOutput;
import java.util.Scanner;
public class Student {
public static void main(String[] args) {
int i= 1,h=0;
while (i<=100){
h+= i;
i++;
}
System.out.println(h);
}
}
public static void main(String[] args) {
int i=1,h=0;
while (i<=100){
if (i%2==0){
h+=i;
i++;
} else{
i++;
continue;
}
System.out.println(h);
}
}
}
public static void main(String[] args) {
int i=1,h=0;
while (i<=100){
if (i%2!=0){
h+=i;
i++;
} else{
i++;
continue;
}
System.out.println(h);
}
}
}
public static void main(String[] args) {
int i=1,h=0;
while (i<=100){
if (i%10==0){
System.out.println(i);
i++;
} else{
i++;
continue;
}
}
}
}
public class Demo13 {
public static void main(String[] args) {
int i=1,h=0,b=0;
while (i<=100){
if (i%2==0){
h+=i;
i++;
} else{
i++;
continue;
}
}
i=0;
while (i<=100){
if (i%2!=0){
b+=i;
i++;
} else{
i++;
continue;
}
}
System.out.println(b-h);
}
}
public class Demo14 {
public static void main(String[] args) {
int i=1;
int sum=0;
while (i<=100){
if (i%5==0){
sum++;
}
i++;
}
System.out.println("5的倍数的个数为:"+sum);
}
}
public class Demo15 {
public static void main(String[] args) {
int i=1;
int sum=0;
while (i<=100){
if (i%2==0){
sum++;
}
i++;
}
System.out.println("100以内的偶数个数为:"+sum);
}
}
public class Demo16 {
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 Demo17 {
public static void main(String[] args) {
int i = 1, h = 0;
while (i <= 100) {
if (i % 2 != 0 & i % 3 == 0) {
System.out.println(i);
}
i++;
}
}
}
public class Demo18 {
public static void main(String[] args) {
int i = 1, h = 0;
while (i <= 100) {
if (i % 2 == 0 && i % 8 == 0) {
h++;
}
i++;
}
System.out.println(h);
}
}
java练习题
最新推荐文章于 2024-08-12 16:47:32 发布