奇偶判断
public static void main(String[]agrs){
Scanner input = new Scanner (System.in);
System.out.println("请输入一个数");
int shu = input.nexut();
if(shu % 2 !=0){ //if(){}elseif(){}判断
System.out.println(shu+"是一个奇数");
}else if (shu % 2==0 ){
System.out.println(shu+"是一个偶数");
}else{
System.out.println("输入错误");
}
}
水仙花数
public static void main(String[] sgrs){
int count = 0;
for(int i = 100;i<1000;i++){
int a=i%10;
int b=(i/10)%10;
int c=i/100%10;
if(a * a * a + b * b * b + c * c * c == i){
count++
System.out.println(i);
}
}
System.out.println("有"+count+"个水仙花数")
}