본문 바로가기
c++/프로그래머스

[프로그래머스] 문자열 반복해서 출력하기(c++)

by ilp 2023. 12. 25.
반응형

https://school.programmers.co.kr/learn/courses/30/lessons/181950

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr



#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    int n;
    
    cin>>s>>n;
    for(int i=0;i<n;i++){
        cout<<s;
    }
    
    return 0;
}

문자열과 정수 변수를 각각 만들어준다.

그리고 입력을 받아준다.

반복문을 사용해서 입력된 정수만큼 문자열을 출력한다


반응형