fjnu 1945 Hello Kitty
2008-02-18 20:09
127 查看
Description
Kitty sends a kind of original email messages to her friend Garf. To write a message, she chooses a word W 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 word W 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:
HelloHelloHello
elloHelloHelloH
lloHelloHelloHe
loHelloHelloHel
oHelloHelloHell
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
Sample Output
KEY:先将字符串复制n次;然后每打印一次后移动;打印次数就是字符数;
Source:
#include<iostream>
#include<cstring>
using namespace std;
char str[1000];
int L;
char s[100];
int len;
int n;
void move()
...{
char t;
t=str[0];
int i;
for(i=0;i<L-1;i++)
str[i]=str[i+1];
str[i]=t;
}
void fun()
...{
int i;
for(i=1;i<=len;i++)
...{
cout<<str<<endl;
move();
}
}
void init()
...{
strcpy(str,"
Kitty sends a kind of original email messages to her friend Garf. To write a message, she chooses a word W 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 word W 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:
HelloHelloHello
elloHelloHelloH
lloHelloHelloHe
loHelloHelloHel
oHelloHelloHell
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 1 Kitty 2 .
Sample Output
Love oveL veLo eLov KittyKitty ittyKittyK ttyKittyKi tyKittyKit yKittyKitt
KEY:先将字符串复制n次;然后每打印一次后移动;打印次数就是字符数;
Source:
#include<iostream>
#include<cstring>
using namespace std;
char str[1000];
int L;
char s[100];
int len;
int n;
void move()
...{
char t;
t=str[0];
int i;
for(i=0;i<L-1;i++)
str[i]=str[i+1];
str[i]=t;
}
void fun()
...{
int i;
for(i=1;i<=len;i++)
...{
cout<<str<<endl;
move();
}
}
void init()
...{
strcpy(str,"
相关文章推荐
- rfc1945-http1.0自译本-(2)
- fjnu 1719 求对数函数值
- fjnu 1715 对称数
- fjnu 1767 相等元素问题
- fjnu 1240 计算循环冗余码
- fjnu 1095 Digital Roots
- fjnu 1419 骑士
- fjnu 1903 数字统计
- fjnu 1744 找鞍点
- fjnu 1840 Reverse Text
- fjnu 1827 Palindrom Numbers
- fjnu 1298 Are We There Yet?
- fjnu 1707 Series Determination
- fjnu 1050 Sum of Factorials
- fjnu 1195 Making Change
- fjnu 1438 黑白图像压缩
- fjnu 1725 分苹果
- fjnu 1713 最长同号连续段
- fjnu 1543 Ones
- fjnu 1417 Raiders of the Lost Ark