2903: A--A Repeating Characters

时间限制: 1 Sec  内存限制: 128 MB

提交: 50  解决: 30

题目描述

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
im0qianqian_站在回忆的河边看着摇晃的渡船终年无声地摆渡,它们就这样安静地画下黄昏画下清晨......

#include <string.h>
#include <stdio.h>
int main()
{
int P,N,num,i=0,j,k;
char c[20];
scanf("%d",&P);
for(k=0; k<P; k++,i=0,puts(""))
{
scanf("%d%d %s",&N,&num,c);
printf("%d ",N);
for(; c[i]!='\0'; i++)
for (j=1; j<=num; j++)
printf("%c",c[i]);
}
return 0;
}

YTU 2903: A--A Repeating Characters的更多相关文章

  1. LeetCode[3] Longest Substring Without Repeating Characters

    题目描述 Given a string, find the length of the longest substring without repeating characters. For exam ...

  2. [LeetCode] Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串

    Find the length of the longest substring T of a given string (consists of lowercase letters only) su ...

  3. [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  4. Longest Substring Without Repeating Characters

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  5. 3. Longest Substring Without Repeating Characters(c++) 15ms

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  6. 【leetcode】Longest Substring Without Repeating Characters

    题目描述: Given a string, find the length of the longest substring without repeating characters. For exa ...

  7. Longest Substring Without Repeating Characters(C语言实现)

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  8. leetcode: longest substring without repeating characters

    July 16, 2015 Problem statement: Longest Substring Without Repeating Characters Read the blog: http: ...

  9. [LeetCode_3] Longest Substring Without Repeating Characters

    LeetCode: 3. Longest Substring Without Repeating Characters class Solution { public: int lengthOfLon ...

随机推荐

  1. laravel 文件删除

    删除文件 <?php class demo{ public function del(){ $disk = Storage::disk('public');//获取磁盘实例 $disk-> ...

  2. [Kubernetes]Volume

    容器技术使用rootfs机制和Mount Namespace,构建出一个同宿主机完全隔离开的文件系统环境 那容器里进程新建的文件,怎么样才能让宿主机获取到?宿主机上的文件和目录,怎么样才能让容器里的进 ...

  3. Asp.Net Thread is being Aborted

    Asp.Net做的一个程序,通过JQuery的Ajax调用,程序执行的数据时间比较长,程序部署到服务器后执行一段时间后就弹出执行失败的对话框,日志记录的错误信息是“正在中止线程”. 查错过程: 1.根 ...

  4. 【POJ1185】炮兵阵地(状压DP)

    题意: 思路:状压DP经典题 可以预处理下每一行内合法的状态,发现很少 所以转移时可以使用状态的编号而不是状态本身 DP时记录前两行状态的编号进行转移和判断 #include<cstdio> ...

  5. 通过复制现有的redhat虚拟机的文件,实现在VMWare8.0上重建一个新的redhat虚拟机环境

    1.将需要复制的redhat虚拟机的文件都存放在一个新的文件夹redhat下,因为虚拟机很大,所以复制可能花费较长的时间. 2.复制完成后,打开VMWare,选择“Open a Virtual Mac ...

  6. php的错误控制运算符

    php的错误控制运算符 PHP中提供了一个错误控制运算符“@”. 可以将@放置在一个PHP表达式之前,该表达式可能产生的任何错误信息都被忽略掉: 如果开启了php.ini 中的 track_error ...

  7. CodeForces 592D Super M

    先把没用的边去掉,求出包含m个点的最小树.然后求出最小树的直径就可以得到答案了. #include <cstdio> #include <cstring> #include & ...

  8. Google C++ style guide——C++类

    1.构造函数的职责 构造函数中仅仅进行那些没有实际意义的初始化.由于成员变量的"有意义"的值大多不在构造函数中确定. 能够的话,使用Init()方法集中初始化为有意义的数据. 长处 ...

  9. django 简易博客开发 2 模板和数据查询

    首先还是贴一下项目地址  https://github.com/goodspeedcheng/sblog   因为代码全在上面 上一篇博客我们介绍了 django的安装配置,新建project,新建a ...

  10. Java入门 第一季第五章 编程练习解析

    这是我学习慕课网Java课程的笔记.原视频链接为:http://www.imooc.com/learn/85 5-1 基本写法 自己主动补全快捷键:alt + / 5-2 输入输出 使用Scanner ...