#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
void string_left_rotate(char* ch, int size, int k)
{
for (int i = 0; i < k; ++i)
{
char ret = ch[0];
for (int j = 1; j < size; ++j)
ch[j - 1] = ch[j];
ch[size - 1] = ret;
}
}
void main()
{
char ch[] = "ABCD";
int size = strlen(ch);
int k;
printf("%s\n", ch);
scanf("%d", &k);
string_left_rotate(ch, size, k);
printf("%s\n", ch);
return 0;
}
【C语言】每日一代码:字符串左旋
最新推荐文章于 2024-10-31 18:26:46 发布