2009년 03월 01일
문제푼것

public class hol {
 protected int n=0;
 public void a(){
  for(int i=0; i<10; i++)
   if(i%2 == 1)
   System.out.print(" " + i);
 }
 
    public void b(){
     int i = 1;
     for(int v=5; v>=i; v--)
      System.out.println(" " + v);      
    }
   
    public void c(){
     for(int i=2; i<10; i++){
      for(int v=1; v<10; v++){
       int c = i * v;
       System.out.println(""+i+"x"+v+"="+c);
      }
     }
    }
   
    public void d(){
     for(int i=1; i<=100; i++){
      System.out.print(" "+ i);
      if(i%10 == 0){
       System.out.println("");
      }
     }
    }
   
    public void e(){
     int n = 20;
     for(int i=1; i<=(n/2); i++){    
      int c = 2 * i;
      System.out.print(" " + c);
      
      if(i%5 == 0){
       System.out.println("");
      }
     }
    }
   
    public void f(){
     int n = 3;
     for(int i=0; i<n; i++){
      for(int c=0; c<n-1-i; c++){
       System.out.print(" ");
      }
      
      for(int v=0; v<1+(i*2); v++){
       System.out.print("*");      
      }
      
      System.out.println("");
     }
    }
   
    public void l(){
     int n=9;
     int sw=0;
     int l=1;
     for(int i=0; i<11; i++){
      
      
      if(i==6){
       l=-1;
      }
      
      sw = sw + l;
      
      for(int c=0; c<sw; c++){
       System.out.print("*");
      }
      System.out.println("");
     }
    }   
}
by 백진영 | 2009/03/01 11:31 | 트랙백 | 덧글(0)
2009년 02월 25일
마름모;종나힘듬

public class retri {
 protected int n=21, sw=1, vw=1, Du=1, vx=2;//n값은 홀수로 줘야 완전한 마름모가나옴
 public void Star(){
  for(int i=0; i<n; i++){
   for(int k=0; k<(n/2)-sw+1; k++){
    System.out.print(" "); 
   
   }
   if(i==(n/2)){
    vw = -1;
    vx = -2;
   }
            sw = sw + vw;
           
            for(int v=0; v<Du; v++){
             System.out.print("*");
            }
            Du = Du + vx;
           
            System.out.println("");
  
  }
 }
}
by 백진영 | 2009/02/25 19:30 | 트랙백 | 덧글(0)


<< 이전 페이지 | 다음 페이지 >>