Hello Kitty

FJNU.1945

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
Love 1
Kitty 2
.

Sample Output
Love
oveL
veLo
eLov
KittyKitty
ittyKittyK
ttyKittyKi
tyKittyKit
yKittyKitt

Source
Colombian National Programming Contest 2006 Warmup

My Program

#include < iostream >
#include
< string .h >
#define  N 255
using   namespace  std;

int  main()
{
    
char str[N];
    
int i,j,n,k;
    
while(cin>>str)
    
{
        
if(!strcmp(str,"."))
            
break;
        n
=strlen(str);
        cin
>>k;
        
for(i=0;i<n;i++)
        
{
            
for(j=i;j<n;j++)
                cout
<<str[j];
            
for(j=1;j<k;j++)
                cout
<<str;
            
for(j=0;j<i;j++)
                cout
<<str[j];
            cout
<<endl;
        }

    }

    
return 0;
}

 YOYO's Note: 
它有多组测试数据……
以前用C写了,大概是因为不会用!=EOF,一直搞不懂为什么WA……
现在无意间写了while的输入……它就AC了……很纠结……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用Python和Pygame库绘制Hello Kitty代码,注释详细说明了每个步骤: ```python import pygame # 初始化Pygame库 pygame.init() # 设置窗口大小和标题 size = (700, 500) screen = pygame.display.set_mode(size) pygame.display.set_caption("Hello Kitty") # 设置颜色 BLACK = (0, 0, 0) WHITE = (255, 255, 255) PINK = (255, 192, 203) # 绘制Hello Kitty def draw_kitty(screen, x, y): # 绘制头部 pygame.draw.ellipse(screen, WHITE, [35 + x, 20 + y, 200, 200]) pygame.draw.ellipse(screen, BLACK, [50 + x, 70 + y, 30, 20]) pygame.draw.ellipse(screen, BLACK, [150 + x, 70 + y, 30, 20]) pygame.draw.ellipse(screen, PINK, [75 + x, 100 + y, 100, 100]) pygame.draw.ellipse(screen, BLACK, [85 + x, 130 + y, 20, 20]) pygame.draw.ellipse(screen, BLACK, [135 + x, 130 + y, 20, 20]) pygame.draw.rect(screen, BLACK, [100 + x, 170 + y, 50, 20]) pygame.draw.ellipse(screen, BLACK, [95 + x, 160 + y, 20, 20]) pygame.draw.ellipse(screen, BLACK, [135 + x, 160 + y, 20, 20]) pygame.draw.polygon(screen, BLACK, [[100 + x, 110 + y], [110 + x, 120 + y], [90 + x, 120 + y]]) pygame.draw.polygon(screen, BLACK, [[150 + x, 110 + y], [160 + x, 120 + y], [140 + x, 120 + y]]) # 绘制身体 pygame.draw.ellipse(screen, WHITE, [20 + x, 200 + y, 260, 200]) pygame.draw.ellipse(screen, BLACK, [20 + x, 200 + y, 260, 200], 1) pygame.draw.ellipse(screen, PINK, [70 + x, 250 + y, 160, 120]) pygame.draw.ellipse(screen, BLACK, [100 + x, 280 + y, 20, 20]) pygame.draw.ellipse(screen, BLACK, [170 + x, 280 + y, 20, 20]) pygame.draw.rect(screen, BLACK, [120 + x, 320 + y, 60, 20]) pygame.draw.ellipse(screen, BLACK, [115 + x, 310 + y, 20, 20]) pygame.draw.ellipse(screen, BLACK, [165 + x, 310 + y, 20, 20]) pygame.draw.polygon(screen, BLACK, [[120 + x, 260 + y], [130 + x, 270 + y], [110 + x, 270 + y]]) pygame.draw.polygon(screen, BLACK, [[190 + x, 260 + y], [200 + x, 270 + y], [180 + x, 270 + y]]) # 设置循环标志 done = False # 游戏循环 while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True # 设置背景颜色 screen.fill(BLACK) # 绘制Hello Kitty draw_kitty(screen, 200, 100) # 更新屏幕 pygame.display.flip() # 退出Pygame库 pygame.quit() ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值