๋ฃจํ”„๋ฅผ ํ•œ๋ฒˆ ๋งŒ ์‚ฌ์šฉํ•œ ์ž๋ฐ” ๊ตฌ๊ตฌ๋‹จ ์†Œ์Šค


์ž๋ฐ”๋กœ ๊ตฌ๊ตฌ๋‹จ ์†Œ์Šค๋ฅผ ์ž‘์„ฑํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

 

continue, break๋ฌธ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , ๋ฃจํ”„๋„ ์ค‘๋ณต ๋ฃจํ”„๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ํ•˜๋‚˜์˜ loop๋ฌธ์„ ์‚ฌ์šฉํ•œ ๊ตฌ๊ตฌ๋‹จ์ž…๋‹ˆ๋‹ค. 


Below java source code prints out multiplication table. 

It does not use nested-loop. It only uses one for-loop. 



public class gugudan {

public static void main(String args[]){

     System.out.println("๊ตฌ๊ตฌ๋‹จ์ž…๋‹ˆ๋‹ค.");
     int i = 1,b = 1;

     while ( i < 10 ) {
          if( b == 10 ) {

              i+=1; 

              b=1;

          }
          if ( i != 10 ) { 

              System.out.println(i+"*"+b+"="+i*b);
              b++;
          }
     }
}

}