본문 바로가기

개발/JAVA

[JAVA] level1 . 직사각형 별찍기 / 표준 입출력

-직사각형 별찍기

 

1. 표준 입출력

Scanner sc = new Scanner(System.in)

int a = sc.nextInt();

 

System.out.print();     //줄바꿈 따로 없이 출력

System.out.println();   //줄바꿈

 

2. 내 소스

import java.util.Scanner;

 

public class Solution {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       int a = sc.nextInt();

       int b = sc.nextInt();

       int i,j;

 

       for(i=0;i<b;i++){

           for(j=0;j<a;j++){

               System.out.print("*");

           }

           System.out.println();

       }

    }

}