求教!为什么已编译完成的文件无法执行??

来源:百度知道 编辑:UC知道 时间:2024/09/20 14:59:17
public class RandomProbability
{
public static void main(String args[])
{
double a;
double b;
int x=2;
if(x>1)
{
for(a=Math.floor(Math.random());a<x;a+=0)
{
a/=x;
}
for(b=Math.floor(Math.random());b<x;b+=0)
{
b/=x;
}
if(a==b)
{
System.out.println("恭喜!");
}
else
{
System.out.println("抱歉!");
}
}
else
{
System.out.println("没什么可恭喜的!肯定就是这个嘛!");
}
}
}

/*x是概率比(例如1%,则x=100)
*a是随机数1
*b是随机数2
*
*随机数1、2都是不大于概率比的正整数或
*当随机数1=随机数2时,条件成立
*
*/

以上是源文件,而且通过编译,但是在执行的时候CMD却无任何显示
请高手赐教!
F1的朋友 谢谢
不过...
for(a=Math.floor(Math.random());a<x;a+=0)
{
a/=x;

在第一个里for循环就成了死循环了,后面的代码根本不执行啊。
你改成这样,就会看到全是恭喜了。
public class RandomProbability
{
public static void main(String args[])
{
double a;
double b;
int x=2;
if(x>1)
{
for(a=Math.floor(Math.random());a<x;a+=0)
{
a/=x;
b=Math.floor(Math.random());
b/=x;
if(a==b)
{
System.out.println("恭喜!");
}
else
{
System.out.println("抱歉!");
}
}

}
else
{
System.out.println("没什么可恭喜的!肯定就是这个嘛!");
}
}
}