Topic: 一起指点一下这段代码,谢谢!!! (break)

  Print this page

1.一起指点一下这段代码,谢谢!!! (break) Copy to clipboard
Posted by: allenlee
Posted on: 2004-09-02 21:31

public class exercise11
{
  public static void main(String args[])
  {
    for(int i=6;i<=100;i+=2){
      outer:for(int j=2;j<100;j++)
      {
        for(int t=2;t<j;t++){
          if(j<i&&j%t!=0)
            System.out.println(i+"="+j+"+"+(i-j));
            else
              System.out.println( );
            if(j%t==0) break outer;
            {
            }
            }
            
        }
      }
    }
  }

这是我写的将歌德巴赫猜想所有等式写出的代码.思路是挺清楚的,可是有个问题:如果我将"outer"label在t的for循环之前,就会有很错误的结果(出现了很多相同的等式),而label在i之前就只出现一个"6=3+3",我想不明白,请大家把其中的运算过程告诉我,好吗??谢谢!!!

2.Re:一起指点一下这段代码,谢谢!!! (break) [Re: allenlee] Copy to clipboard
Posted by: why
Posted on: 2004-09-02 22:08

请先把那些括号弄清楚
不要随便扔上来,教人看得辛苦。Sad

3.Re:一起指点一下这段代码,谢谢!!! (break) [Re: allenlee] Copy to clipboard
Posted by: allenlee
Posted on: 2004-09-02 22:22

括号.....就是对不齐~
真是对不起~

4.Re:一起指点一下这段代码,谢谢!!! (break) [Re: allenlee] Copy to clipboard
Posted by: why
Posted on: 2004-09-03 03:11

不仅对不齐
更用了多种 style
而且可能有误
例如

if(j%t==0) break outer;
{
}


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923