java输出九九乘法表

写一个用java语言写成的九九乘法表,要求用两个while语句写成,不要用for循环!!!
class TwoWhile
{
public static void main(String [] args)
{
int x=1;
int y=1;
while(x<=9)
{
while(y<=9)
{
System.out.println(x+"*"+y+"="+x*y);
y++;

}
x++;
}
}
}
为什么我这样写不行呢???

第1个回答  推荐于2016-03-06
取个名字不容易,你把我分析的结果和楼主整合写个程序算什么啊!太过分了吧,而且你的是错的!!

楼主你的y 自++到10没有回到1当,x=2时候y已经=10了所以什么都不执行,下面是我刚写好的
public class Ex4 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i=1;
int j=1;
out: while(i <= 9)
{

while(j <= 9)
{
System.out.print(j + "*" + i + "=" + j * i + " ");

if(i == j)
{
i++;
j=1;
System.out.print("\n");

continue out;
}
else
{ j++;
}
}
}

}

}
试试我的本回答被提问者采纳
第2个回答  2008-04-03
public class TwoWhile
{
public static void main( String [] args)
{
int i = 1;

while( i <= 9)
{
int j = 1;
while( j <= i)
{
System.out.printf( "%d*%d=%-3d", j, i, i * j);
j++;
}
System.out.println();
i++;
}
}
}
第3个回答  2008-04-03
int i = 1;
int j = 1;
while(i <= 9) {
while(j<=i) {
System.out.print(i*j + " ");
j++;
}
i++;
j = 1;
System.out.println();
}

-------------------------------------
这个行
-----------------------------------------------
。。。。。。无语,写这个还需要看你了。。。不就点分么````没品
相似回答