본문 바로가기

Web Dev/JAVA

목이 뻐근타


/**

 * @author aram.park

 * 주어진 배열을 시계방향으로 90도 회전시켜서 출력하는 프로그램 

 *

 */

public class Excercise5_9 {


    public static void main(String[] args) {

        char[][] star =

                { { '*', '*', ' ', ' ', ' ' }, { '*', '*', ' ', ' ', ' ' }, { '*', '*', '*', '*', '*' }, { '*', '*', '*', '*', '*' } //[4][5]

                };


        char[][] result = new char[star[0].length][star.length];//[세로][가로]


        for (int i = 0; i < star.length; i++) {

            for (int j = 0; j < star[i].length; j++) {

                System.out.print(star[i][j]);

            }

            System.out.println();

        }

        System.out.println();


        for (int i = 0; i < star.length; i++) { //反対に入れる。

            for (int j = 0; j < star[i].length; j++) {

                //result[i][j]=star[star.length-1-i][i];

                result[j][star.length - 1 - i] = star[i][j];

            }

            System.out.println();

        }

        for (int i = 0; i < result.length; i++) {

            for (int j = 0; j < result[i].length; j++) {

                System.out.print(result[i][j]);

            }

            System.out.println();

        }

    }

}

'Web Dev > JAVA' 카테고리의 다른 글

오늘의 java 예외처리  (0) 2015.05.12
예외처리 오늘 분 // 이해필요  (0) 2015.05.12
주말엔 취미로 프로그래밍  (0) 2015.04.26
배열가지고놀기  (0) 2015.04.24
Object Class  (0) 2015.04.24