Java/알고리즘
직사각형 별찍기
티코딩
2024. 2. 2. 11:10
ㅇ 풀이
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
String star = "*";
String Star = "";
int i = 0;
while(i < a){
Star += star;
i++;
}
for(int j = 0; j < b; j++){
System.out.println(Star);
}
}
}
먼저 *를 a만큼 붙혀보자.
while문을 통해서 star를 a개를 붙히고, b만큼 출력을하면된다.
쏘 이지.