22018, 1/1101 회원가입  로그인  
   jaesungp8
   http://jaesungp8.blog.me/
   자바 문제입니다.

http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=31703 [복사]


자바로 해결하고있는데,
*****
****
***
**
*
**
***
****
*****

위와같은 모양을 만드는건데,
제코드는

public class WildcardPilamidMain {
        public static void main(String args[]) {
                
                int Switch=1;

                for(int i = 9 ; 9>=i && i>=(-9)  ; i--) {
                        
                        if(i==0) {
                                System.out.print("*");
                                Switch=(-1);
                        }
                        for(int j = i*Switch ; j >= 0 ; j--) {
                                if(i!=0) {
                                        System.out.print("*");
                                }
                        }
                        
                        System.out.println();
                }
        }
}

이런식으로 했는데, 더 좋은 방법이 없을까 합니다,,
for문을 두개만 사용해야되는데, 뭔가 다른 간결한 방법은 없을까요..

  Hit : 10806     Date : 2014/03/27 03:46



    
minipaik07 5x10해서 정사각형 만드실줄은 아시나요? 2015/07/28