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)