影音先锋男人资源av站_狠狠色综合激情丁香五月_爱爱爱爱看视频_在线播放免费人成视频在线观看_少妇人妻综合久久中文字幕_国产午夜无码精品免费看_久久久久久夜精品精品免费啦_男人女人午夜视频免费_日本xxxx裸体xxxx_丰满人妻熟妇乱又仑精品
電子科大論壇-非清水河畔
標題:
請JAVA高手指教
[打印本頁]
作者:
光輝歲月
時間:
2006-6-1 22:46
標題:
請JAVA高手指教
JAVA高手幫我看一下這個程序有什么問題啊
這是:
驗證“哥德巴赫猜想”:任何大于6的偶數(shù)均可以表示為兩個素數(shù)之和。
class yanss
{
boolean yan(int x)
{
int s=0;
for (int i=1;i<=x ;i++ )
{
if ((x%i)==0) s++;
}
if (s==2) return true;
}
}
class test
{
public static void main(String[] args)
{
int n=0;
for (int a=8;a<=100 ;a +=2 )
{
yanss ob=new yanss();
if (ob.yan(a)) n++;
}
if (n==47) System.out.println("猜想正確啊!!");
}
}
最后編繹出現(xiàn)這個錯誤:missing return statement
作者:
xiaohui20031984
時間:
2006-6-3 15:33
標題:
注意在if的另一種情況的返回值啊
class yanss
{
boolean yan(int x)
{
int s=0;
for (int i=1;i<=x ;i++ )
{
if ((x%i)==0) s++;
}
if (s==2) return true;
return false;
}
}
class test
{
public static void main(String[] args)
{
int n=0;
for (int a=8;a<=100 ;a +=2 )
{
yanss ob=new yanss();
if (ob.yan(a)) n++;
}
if (n==47) System.out.println("猜想正確啊!!");
}
}
作者:
光輝歲月
時間:
2006-6-3 18:26
標題:
多謝了但還一個問題啊
這個程序好像還是錯的啊
高手還能不能幫一下小弟啊
語法現(xiàn)在沒有錯了
歡迎光臨 電子科大論壇-非清水河畔 (http://www.hallmarkedu.com/)
Powered by Discuz! X3.4