(2012-3)字符串的重复输出(水题)

题目描述:

给一个字符串比如ABC 再给一个整数比如3.输出AAABBBCCC就行了

#include <string>
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
    string str;
    getline(cin, str);
    int n;
    cin >> n;
    for(int i = 0; i < str.size(); i++){
        for(int j = 0; j < n; j++){
            printf("%c", str[i]);
        }
    }
    printf("\n");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_35093872/article/details/88090992
今日推荐