1218: String Shift left

Source: Internet
Author: User

From: Co-worker Xuan OJ http://xcacm.hfut.edu.cn/problem.php?id=1218

Time limit: 1 Sec memory limit: 2 MB

The title describes a string with a length equal to N, and a string that moves the M-bit to the left.

Input

Two rows per set of data, the first row N m,0<=n<=1000,0<=m<=1500 the second row gives the string, and the string contains only uppercase and lowercase letters.

Output

Outputs the result after the left shift.

Sample input

6 3 Netcan 6 2 Netcan 4 HelloWorld

Sample output

CanNet Tcanne Oworldhell

The crux of the problem is that the length of the left shift of the string may be greater than the length of the string itself, then the implementation program should be able to cycle search, with the% to take the remainder of the simplification.

1#include <iostream>2#include <stdio.h>3#include <string.h>4 using namespacestd;5 intMain ()6 {7     Chard[1550];8     inta,b,i,j,c;9      while(SCANF ("%d%d", &a,&b)! =EOF)Ten     { One  ACin>>D; -         if(b==0) {cout<<d<<Endl;} -         Else{ theC=strlen (d); -b=b%A; -          for(j=b;j<a;j++) -         { +printf"%c", D[j]); -         } +          for(j=0; j<=b-1; j + +) A         { atprintf"%c", D[j]); -         } -          for(j=a;j<c;j++) -         { -printf"%c", D[j]); -         } in          for(i=0; i<=c;i++) -         { tod[i]=0; +         } -printf"\ n"); the       } *     } $     return 0;Panax Notoginseng } - /************************************************************** the problem:1218 + user:2014217052 A language:c++ the Result: Correct + time:34 Ms - memory:1504 KB $ ****************************************************************/

1218: String Shift left

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.