计科140201125 王振禹 作业二
public class One{
public static void main(String[] args){
int i,a,b,c;
for(i=100;i<=999;i++){
a=(i/100)*(i/100)*(i/100);
b=((i%100)/10)*((i%100)/10)*((i%100)/10);
c=(i%10)*(i%10)*(i%10);
if((a+b+c)==i){
System.out.println("水仙花:"+i);
System.out.println("\n");
}
}
}
}
public class Two{
public static void main(String[] args){
int x,s=0,i;
for(i=1;i<=100;i++){
if(i%2==1){
x=1;
}
else{
x=-1;
}
s=s+i*10*x;
}
System.out.println("和为:"+s);
}
}
public class Three{
public static void main(String[] args){
for(int i=1;i<=1000;i++){
if(i%3==0&&i%5==0&&i%7==0){
System.out.println(i);
}
}
}
}
public class Four{
public static void main(String[] args){
long s=0,x=1;
for(int i=1;i<=20;i++){
x=x*i;
s=s+x;
}
System.out.println("和为:"+s);
}
}