문제출처
programmers.co.kr/learn/courses/30/lessons/12969
문제설명
이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다.
별(*) 문자를 이용해 가로의 길이가 n, 세로의 길이가 m인 직사각형 형태를 출력해보세요.
제한사항
- n과 m은 각각 1000 이하인 자연수입니다.
입출력 예
입력
5 3
출력
*****
*****
*****
문제풀이
입력받은 두 수 중 첫번째 수만큼의 "*"를 두번째 수만큼 반복해서 출력하면 되는 아주 간단한 문제이다.
String(repeating: , count: )를 사용하면 정말 간단하게 해결할 수 있다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in 0..<b { | |
let star = String(repeating: "*", count: a) | |
print(star) | |
} |
'코딩테스트' 카테고리의 다른 글
프로그래머스 - 비밀지도 (레벨1, swift) (0) | 2020.06.28 |
---|---|
프로그래머스 - 실패율 (레벨1, swift) (0) | 2020.06.28 |
프로그래머스 - 이상한 문자 만들기 (레벨1, swift) (0) | 2020.06.27 |
프로그래머스 - x만큼 간격이 있는 n개의 숫자 (레벨1, swift) (0) | 2020.06.27 |
프로그래머스 - 최대공약수와 최소공배수 (레벨1, swift) (0) | 2020.06.26 |