
나의 풀이
import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
for(int x = 0; x < b ; x++){
for(int y = 0 ; y < a ; y++){
System.out.print("*");
}
System.out.println();
}
}
}
다른 사람의 풀이
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();
String str = "";
for(int i=0 ; i<b; i++){
for(int j = 0; j<a; j++){
str += "*";
}
str+="\n";
}
System.out.println(str);
}
}
'알고리즘' 카테고리의 다른 글
| [프로그래머스] 3진법 뒤집기(Java) * (0) | 2024.11.24 |
|---|---|
| [프로그래머스] 최대공약수와 최소공배수(Java) (0) | 2024.11.23 |
| [프로그래머스] 문자열 다루기 기본(Java) (0) | 2024.11.21 |
| [프로그래머스] 부족한 금액 계산하기(Java) (2) | 2024.11.19 |
| [프로그래머스] 문자열 내림차순으로 배치하기(Java) (0) | 2024.11.18 |