浙大版《C语言程序设计(第3版)》题目集 练习8-8 移动字母 (10分)

在这里插入图片描述

#include <stdio.h>
#include <string.h>
#define MAXS 10
void Shift(char s[]);
void GetString(char s[]); /* 实现细节在此不表 */
int main()
{
    char s[MAXS];
    GetString(s);
    Shift(s);
    printf("%s\n", s);
    return 0;
}
void Shift(char s[])
{
    int i, j;
    char temp;
    for (i = 0; i < 3; i++)
    {
        temp = s[0];
        for (j = 0; s[j] != '\0'; j++)
        {
            s[j] = s[j + 1];
        }
        s[j - 1] = temp;
        s[j] = '\0';
    }
}
发布了251 篇原创文章 · 获赞 117 · 访问量 8525

猜你喜欢

转载自blog.csdn.net/qq_44458489/article/details/105354824