基本while循环的问题 [英] problem with basic while loop

查看:78
本文介绍了基本while循环的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,这是一个稀疏矩阵的一部分,我有一个问题,在一个while循环之前和之后的事情打印,代码基本上在开始时有

System.out.print( 列号+测试abcd);如果你编译后可以打印,但是在while循环结束后,为什么第二个打印输出语句不起作用

System.out .print(列号+ colNumber +test efgh); ,

这几乎是一直到底。

while循环后的这个打印语句不打印出来。

这是基本上我遇到的问题。



有谁能告诉我这是什么问题?



谢谢



------------------------------







这是代码:





hello this is a part of a sparsematrix , I have a questions with the printing of things before and after a while loop , the code basically at the begining has
" System.out.print("column number " + " test abcd "); " which can get printed if you compile however after the while loop has been finished then why does the second print out statement not work which is
System.out.print("column number " + colNumber + " test efgh "); ,
this is almost all the way down the bottom .
This print statement after the while loop does not get printed out .
This is basically the problem I am having .

Can anybody tell me what the problem is ?

Thank you

------------------------------



Here is the code :


public void print(int number)
   {
                  System.out.print("column number " + "  test abcd ");

               int countr = 0;
               int cntr = 0;

       number = 0;
       while( number == number )
       {
                if(!see_column(number))
                {
                  return;
               }

            Node columnitr = enter;
            while(columnitr.getcolmn() != number)
                {
                columnitr = columnitr.getright();
                }

            Node rowitr = columnitr;
            while(rowitr.getdown() != columnitr)
               {

                rowitr = rowitr.getdown();
             System.out.print("   ("+rowitr.getrow()+"  , "
                      +rowitr.getcolmn()+  "  )  :  "
                            +rowitr.getvalue());
                }

              number++;
              countr = rowitr.getcolmn();

              cntr = countr + 1;
              if (cntr > countr)
              {
              System.out.println("number of columns : "  +  cntr);
              System.out.print("column number " + colNumber + " -- ");
            }
       }


     System.out.print("column number " + colNumber + "  test efgh ");



   }

推荐答案

" System.out.print("column number " + " test abcd "); " which can get printed if you compile however after the while loop has been finished then why does the second print out statement not work which is
System.out.print("column number " + colNumber + " test efgh "); ,





你确定循环已经完成了吗?



在你的循环条件下,你把:​​





Are you sure the the while loop has been finished running?

In your looping condition, you put:

while( number == number )





Ares那些数字 s是相同还是不同?如果它们是相同的,那么有什么方法可以使这两个数字在循环继续时不同?如果没有,循环将如何破坏?



虽然我问所有问题而不是回答,但我认为你可以自己找到答案。



- DP



Ares those numbers are same things or different? If they are the same, is there any way so that those two numbers will different while the loop continues? If not, how the loop will break?

Though I am asking all the questions instead of answering, I think you can find the answer by yourself.

- DP


这篇关于基本while循环的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆