[코드트리] - 특정 문자열을 출력하는 함수

LSDrug·2024년 8월 7일
0

문제풀이

목록 보기
12/21

특정 문자열을 출력하는 함수 ⭕


문제

https://www.codetree.ai/training-field/search/problems/function-that-outputs-specific-string?&utm_source=clipboard&utm_medium=text


풀이

역시 쉬운 문제, 함수를 하나 만들고 그 함수를 반복문만큼 반복 출력하게 하면 된다.


코드

#include <iostream>
using namespace std;

void show();

int main() {
    
    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
        show();
    }

    return 0;
}

void show() {

    cout << "Hello" << endl;
    cout << "#@#@#@#@#@" << endl;
    cout << "CodeTree" << endl;
    cout << "@#@#@#@#@#" << endl;
    cout << "Students!" << endl;
    cout << endl;
}

profile
마약같은 코딩, 마약같은 코딩러

0개의 댓글

관련 채용 정보