写了.不晓得错在哪里importjava.io.*;publicclassHana{staticIntegerShuixian(intx){booleanp=true;inty;intr=0,s=0,t=0;r=x%10;s=(x%100)/10;t=x/100;y=r*r*r+s*s*s+t*t*t;if(x==y)p...
写了.不晓得错在哪里
import java.io.*;
public class Hana{
static Integer Shuixian(int x){
boolean p=true;
int y;
int r=0, s=0,t=0;
r=x % 10;
s=( x % 100 )/10;
t= x / 100;
y=r*r*r+s*s*s+t*t*t;
if ( x == y )
p=true;
if ( x != y )
p=false;
if (p==true)
System.out.println("该数是水仙花数");
if (p==false)
System.out.println("该数不是是水仙花数");
return y;
}
public static void main(String args[])throws IOException{
int i;
String str;
BufferedReader buf;
buf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Input an number:");
str=buf.readLine();
i=Integer.parseInt(str);
double a= Shuixian(i);
System.out.println(a);
}
}
展开