5-31 string Loop left shift (20 points)

Source: Internet
Author: User

Entering a string and a non-negative integer n requires that the string be cycled to the left N times.

Input format:

The input gives a non-empty string that is not more than 100 characters in length in line 1th and ends with a carriage return, and the 2nd line gives a nonnegative integer N.

Output format:

Outputs a string in a row After the loop has shifted left N times.

Input Sample:
Hello World!2
Sample output:
llo World!He

#include <stdio.h> #include <stdlib.h>int main () {int N;int length = 0;char a[100],b[100];gets_s (a); scanf_s ( "%d", &n); char *p = A;while (*p! = ') {p++;length++;} n = n length;for (int i = 0; i < N; i++) {b[i] = a[i];} for (int i = N; i < length; i++) {a[i-n] = a[i];} for (int i = 0; i < N; i++) {a[length-n + i] = b[i];} printf_s ("%s", a); return 0;} /* Your code will be embedded here */

  

5-31 string Loop left shift (20 points)

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.