웅재의 코딩세상

[프로그래머스] 수박수박수박수박수박수? 본문

코딩테스트/프로그래머스 - LV 1

[프로그래머스] 수박수박수박수박수박수?

웅드 2024. 2. 9. 17:22

 

  • 풀이
#include <string>
#include <vector>

using namespace std;

string solution(int n) {
    string answer = "";
    for(int i=0; i< n/2; i++){
        answer += "수박";
    }
    if(n%2 == 1) answer += "수";
    return answer;
}
반응형