본문 바로가기
프로그래밍/자바의정석_4_연습문제

[4-5] 다음의 for문을 while문으로 변경하시오.

by 므시칸곰틔군 2014. 8. 5.


public class ex_005 {

 // [4-5] 다음의 for문을 while문으로 변경하시오.
 // [연습문제]/ch4/Exercise4_5.java
 // public class Exercise4_5 {
 // public static void main(String[] args) {
 // for(int i=0; i<=10; i++) {
 // for(int j=0; j<=i; j++)
 // System.out.print("*");
 // System.out.println();
 // }
 // } // end of main
 // } // end of class
 // 결과.
 // *
 // **
 // ***
 // ****
 // *****
 // ******
 // *******
 // ********
 // *********
 // **********
 // ***********

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub

  int i = 0;
  while (i <= 10) {
   int j = 0;
   while (j <= i) {
    System.out.print("" + j);

System.out.print("*");
    j++;
   }
   System.out.println("");
   i++;
  }
 }
 // 0
 // 01
 // 012
 // 0123
 // 01234
 // 012345
 // 0123456
 // 01234567
 // 012345678
 // 0123456789
 // 012345678910

}