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. Java 新手学习日记一

    Java 基础知识点掌握: 数据类型 变量就是申请内存来存储值.也就是说,当创建变量的时候,需要在内存中申请空间.内存管理系统根据变量的类型为变量分配存储空间,分配的空间只能用来储存该类型数据. 因此 ...

  2. ASP.NET MVC WebAPI请求

    基础: 首先,先创建一个“ASP.NET 空Web应用程序” : 然后添加对 “System.Web.Http” 和 “System.Web.Http.WebHost” 的引用: 再添加对“Syste ...

  3. var声明的成员变量和函数内声明的变量区别

    1.函数内部,有var声明的是局部变量,没var的,声明的全局变量. 2.在全局作用域内声明变量时,有var 和没var声明的都是全局变量,是window的属性.通过变量var声明全局对象的属性无法通 ...

  4. Linux基础之基本命令cat less more sort uniq alias 命令行 bash简单描述(三)

    获取Linux当前最新的内核版本号经常关注www.kernel.org 目录管理:ls cd pwd mkdir rmdir tree 文件管理:touch stat file rm cp mv na ...

  5. [CTSC2007]数据备份Backup 题解

    题意: 一维直线上有n个点,任取2k个互不相同的点组成k条链,求链的最小总长 思路: 1.最优时链不相交,相邻两两相减,将题目转化为:在n-1个数中取互不相邻的k个数使总和最小. 2.贪心取最小的“数 ...

  6. bzoj 3786 星系探索 dfs+splay

    [BZOJ3786]星系探索 Description 物理学家小C的研究正遇到某个瓶颈. 他正在研究的是一个星系,这个星系中有n个星球,其中有一个主星球(方便起见我们默认其为1号星球),其余的所有星球 ...

  7. firefox自动化测试的常用插件

    1.firebug 2.firepath 3.firefinder 5.WebDriver Element Locator 提供多种语言的xpath路径

  8. 前端学习之-- DOM

    Dom == document 1:查找 1:直接查找 document.getElementById('i1') # 根据ID获取一个标签(获取单个元素) document.getElementsB ...

  9. js的offsetWidth,clientWidth

    js元素的offsetWidth与clientWidth很相似,因此放在一起记录. clientWidth与offsetWidth clientWidth=元素内容区域宽度+水平内边距padding. ...

  10. loj6173 Samjia和矩阵(后缀数组/后缀自动机)

    题目: https://loj.ac/problem/6173 分析: 考虑枚举宽度w,然后把宽度压位集中,将它们哈希 (这是w=2的时候) 然后可以写一下string=“ac#bc” 然后就是求这个 ...