【问题描述】
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 ‘rotateand- 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?
【输入】
The input file 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 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.
The output must be written to standard output.
【样例输入】
Love 1
Kitty 2
.
【样例输出】
Love
oveL
veLo
eLov
KittyKitty
ittyKittyK
ttyKittyKi
tyKittyKit
yKittyKitt
【题目大意】
简化一下题目意思,首先输入一个字符串,然后输入一个整型数字,例如:Hello 2,则首先先输出HelloHello,然后进行字符串的偏移,就是说下一个输出的是elloHelloH,然后是lloHelloHe,依次类推,知道这个字符串下一次偏移将会变成自己,则停止,这个例子的话,就是到oHelloHell结束,另外如果输入的字符串是“.”,不做处理,停止程序
【实现思路】
这个就很容易了,就是首先根据输入的k创造出最原始的字符串,然后在进行一位一位的偏移的即可,判断边界条件即可
【实现代码】

#include<iostream>
#include<string.h>
using namespace std;
int main()
{string str;string tmp;while(cin>>str){tmp=str;if(str==".")return 0;else{int n;cin>>n;int length1=str.length();for(int i=1;i<n;i++){str+=tmp;}cout<<str<<endl;int length2=str.length();for(int i=0;i<length1-1;i++){char temp=str[0];for(int j=0;j<length2-1;j++){str[j]=str[j+1];}str[length2-1]=temp;cout<<str<<endl;}}}return 0;
}

【10639 Hello Kitty】相关推荐

  1. 信息学奥赛一本通 2032:【例4.18】分解质因数

    [题目链接] ybt 2032:[例4.18]分解质因数 [题目考点] 1. 质数 [解题思路] 解法1:使用循环 每次循环中,遍历2到n,找到一个n的质因数,输出,而后n除以该因数,继续循环. 解法 ...

  2. 【进阶3-4期】深度解析bind原理、使用场景及模拟实现

    bind() bind() 方法会创建一个新函数,当这个新函数被调用时,它的 this 值是传递给 bind() 的第一个参数,传入bind方法的第二个以及以后的参数加上绑定函数运行时本身的参数按照顺 ...

  3. 【JavaSE进阶(上)】自学笔记 记得收藏时时回顾

    final关键字 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Y4clTw5g-1649075023636)(https://cdn.nlark.com/yuque/ ...

  4. 【Scala笔记——道】Scala 循环遍历 for详解

    Scala for循环 基本使用 增强型for循环 scala基本for循环如下,代码将names遍历并打印包含的名字. val names = Seq("Kitty", &quo ...

  5. ui九宫格切图_【九宫切图】什么是九宫绘图,九宫格绘法

    九宫切图在控件美化的时候会经常的用到 比如: 20140630220626_56850.png (3.13 KB, 下载次数: 42) [九宫切图]什么是九宫绘图,九宫格绘法 2014-7-21 11 ...

  6. 【Python自然语言处理】读书笔记:第三章:处理原始文本

    本章原文链接:https://usyiyi.github.io/nlp-py-2e-zh/3.html 3 处理原始文本 import nltk, re, pprint from nltk impor ...

  7. QT当中的【QSetting和.ini配置文件】以及【创建Resources.qrc】

    QT当中的[QSetting和.ini配置文件]以及[创建Resources.qrc] [1] 创建QT下的.qrc [2]QSetting+.qrc使用 [3]代码实现 main.cpp mainw ...

  8. 【玩转SpringBoot】翻身做主人,一统web服务器

    寄人篱下的日子 一直以来受传统影响,我们的web工程总是打成war包,然后放入tomcat的webapps目录下面. 如下图01: 当tomcat启动时,会去解压war包,然后运行web工程.这大家都 ...

  9. 是否存在分布式的【大泥球】?

    2021-11-11 15:08 是否存在分布式的[大泥球]? 人们往往把微服务架构当成一剂良药,用以解决单体应用内的大泥球问题.然而,大泥球的本质问题是因为代码都位于同一个进程里运行的吗?换言之,如 ...

最新文章

  1. 信息技术守护人类文明DNA
  2. 三方支付(支付宝为例)
  3. Silverlight C# 游戏开发:资源的处理,图像算法(二)
  4. Oracle 数据字典表 -- SYS.COL$
  5. cmd中如何查看当前绝对路径_如何查看 Linux 中文件打开情况?
  6. QT的foreach用法
  7. python必看经典书籍:笨办法学python
  8. 机器学习分类问题中_训练数据类别不均衡怎么解决
  9. ES6学习笔记五(对象)
  10. kafka的发行版选择
  11. 图书馆管理系统(数据库版)
  12. html 设置整体字体,html font标签如何设置字体样式
  13. python删除表格第一行不动_Excel教程,教你如何设置表格第一行和第一列固定不动,一直显示...
  14. DNSPod-免费智能DNS解析服务商
  15. 【与时俱进,智慧社区应运而生】
  16. 程序媛们,女神节快乐~
  17. (OS 10038)在一个非套接字上尝试了一个操作 的解决办法
  18. l100_Issuer_test 使用说明
  19. 2022年系统集成企业的物联网平台首选:物联集成平台
  20. macOS如何重装系统

热门文章

  1. 色光三原色RGB相加减
  2. php 数组 时间戳排序,php – 按时间戳排序Summed Collection
  3. 大学计算机作业互评评语简短,大学学生互评评语100字简短
  4. 婚宴座位图html5,大型婚宴 婚礼座位安排(图)
  5. Debian安装docker全流程
  6. 数据结构课程设计---实现一元稀疏多项式计算器
  7. 计算机英语反思总结怎么写,英语考试反思总结(精选10篇)
  8. 360wifi在linux系统如何使用,在树莓派上使用360WIFI(也适用于小米、百度、腾讯WIFI)...
  9. 深度学习论文阅读目标检测篇(七)中英对照版:YOLOv4《Optimal Speed and Accuracy of Object Detection》
  10. 为什么公众号总是显示服务器不正常,“该公众号提供的服务出现故障,请稍后再试”问题的处理办法...