2491 Hello Kitty
来源:互联网 发布:咫尺网络南京 编辑:程序博客网 时间:2024/06/11 03:06
一次性AC了,tju上的水题,就是字符串重复然后移位。
Kitty sends a kind of original email messages to her friend Garf. To write a message, she chooses a wordW and a number n and replicates W n times horizontally. Then she repeats this string in the next line, but rotating the characters once to the left. And she repeats this 'rotate-and-output' process until the wordW appears displayed as the first column of the rectangular pattern that she produces.
As an example, when she chooses the word Hello and the number 3, she gets the pattern:
HelloHelloHelloelloHelloHelloHlloHelloHelloHeloHelloHelloHeloHelloHelloHell
Kitty has been sending such emails during the last three years. Recently, Garf told her that perhaps her work may be automatized with a software to produce Kitty's patterns. Could you help her?
Input
The input contains several test cases, each one of them in a separate line. Each test case has a word and a positive integer that should generate the corresponding rectangular pattern. The word is a string of alphabetic characters (a..z). The number is less than 10.
A line whose contents is a single period character means the end of the input (this last line is not to be processed).
Output
Output texts for each input case are presented in the same order that input is read. For each test case the answer must be a left aligned Kitty pattern corresponding to the input.
Sample input
Love 1Kitty 2.
Output for the sample input
LoveoveLveLoeLovKittyKittyittyKittyKttyKittyKityKittyKityKittyKitt
#include<iostream>#include<string>using namespace std;int main(){string s,c;char a;int n,i,l;while(cin>>s){l=s.length();//cout<<l<<endl;if(l==1)break;cin>>n;c=s;for(i=0;i<n-1;i++)s=s+c;cout<<s<<endl;for(int k=0;k<l-1;k++){a=s[0];for(int j=0;j<l*n-1;j++){s[j]=s[j+1];}s[l*n-1]=a;cout<<s<<endl;}//cout<<n<<" "<<s<<endl;}return 0;}
- 2491 Hello Kitty
- Hello Kitty
- Hello Kitty
- Hello Kitty!
- fjnu 1945 Hello Kitty
- andorid 第二天 hello kitty
- Hello Kitty & 多摩中心
- 袜子上的Hello kitty
- andoird 第三天 详解 "Hello Kitty"
- Let 's Study C++ Here ,hello kitty!
- PyQt4 精彩实例分析* 实例1 Hello Kitty!
- PyQt4 精彩实例分析* 实例1 Hello Kitty!
- hello kitty tyvj begin 不能再水了 字符串输入
- 秋老虎不发威,我当你是Hello Kitty
- PyQt4 精彩实例分析 实例1 Hello Kitty!
- XAML 实例演示之九 – Hello Kitty 专卖店产品演示
- Hello Kitty在线数据库泄露 330万粉丝信息受到影响
- Kitty靓图
- javascript KeyDown、KeyPress和KeyUp事件的区别与联系
- 14 会场安排问题
- android ViewPager学习(二)创建自定义标题
- C++大学基础教程_11_8_实例研究:Array类
- hdu 4604 DP
- 2491 Hello Kitty
- ubuntu 更改root 权限
- 判断一个整数是不是2的整数幂
- HUDJ Wooden Sticks 贪心
- NSInteger和int的区别与使用方法
- 计算机视觉代码合集
- 16 矩形嵌套
- 博弈---巴什博奕(Bash Game)(博弈入门)
- 一个a标签刷新问题