Description
For this problem, you will write a program that takes a string of characters, S, and creates a new string of characters, T, with each character repeated R times. That is, R copies of the first character of S, followed by R copies of the second character of S, and so on. Valid characters for S are the QR Code ``alphanumeric'' characters:
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ$%*+-./:
Input
The first line of input contains a single integer P, ( 1P1000), which is the number of data sets that follow. Each data set is a single line of input consisting of the data set number N, followed by a space, followed by the repeat count R, ( 1R8), followed by a space, followed by the string S. The length of string S will always be at least one and no more than 20 characters. All the characters will be from the set of characters shown above.
Output
For each data set there is one line of output. It contains the data set number, N, followed by a single space which is then followed by the new string T, which is made of each character in S repeated R times.
Sample Input
2 1 3 ABC 2 5 /HTP
Sample Output
1 AAABBBCCC 2 /HHHHHTTTTTPPPPP
题型:大水题
题意:就是将字符串中的每个字符重复输出p遍。
分析:话说这批题目还真是奇葩,还要输出行号,一开始咋都木有看懂这最前面的数是啥子玩意儿,结果发现单纯的我被这单纯的行号给单纯地伤害了。。。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
char s[50];
int main(){
int t,n,p;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d%s",&n,&p,s);
printf("%d ",n);
for(int i=0;i<strlen(s);i++){
int cnt=0;
while(cnt<p){
printf("%c",s[i]);
cnt++;
}
}
printf("\n");
}
}
return 0;
}