A--A Repeating Characters

2020年1月17日 695点热度 0人点赞 0条评论

A--A Repeating Characters

时间: 1ms        内存:128M

描述:

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$%*+-. /:

输入:

The first line of input contains a single integer P,(1<=P<=1000),which is the number of data sets that follow. Each data set is single line of input consisting of the data set number N,followed by a space,followed by the repeat count R,(1<=R<=8),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.

输出:

For each data set there is one line of output. It contains the data set number,
N, followed by a single apace which is then followed by the new string T,which is made of each character in S repeated R times.

示例输入:

2
1 3 ABC
2 5 /HTP

示例输出:

1 AAABBBCCC
2 /////HHHHHTTTTTPPPPP

提示:

参考答案:

解锁文章

没有看到答案?微信扫描二维码可免费解锁文章

微信扫描二维码解锁

使用微信扫描二维码打开广告页面后可以立即关闭,再刷新此页面即可正常浏览此文章

所跳转广告均由第三方提供,并不代表本站观点!

已经扫描此二维码?点此立即跳转

code

这个人很懒,什么都没留下

文章评论