C++)
#include <string>
using namespace std;
string solution(int n) {
string answer = "";
for(int i = 0; i < n/2; i++)
answer += "수박";
answer += (n%2 == 1) ? "수" : "";
return answer;
}
Python)
def solution(n):
return "수박" * (n//2) + "수" * (n%2)'프로그래머스 > Level1' 카테고리의 다른 글
| [Level1] 푸드 파이트 대회 (C++/Python) (0) | 2023.02.07 |
|---|---|
| [Level 1] 시저 암호 (C++/Python) (0) | 2021.01.08 |
| [Level 1] 문자열을 정수로 바꾸기 (C++/Python) (0) | 2021.01.08 |
| [Level 1] 서울에서 김서방 찾기 (C++/Python) (0) | 2021.01.08 |
| [Level 1] 소수 찾기 (C++/Python) (0) | 2021.01.08 |