摆烂大学生


私信TA

用户名:dotcpp0686626

访问量:1495

签 名:

把喜欢的都留在身边,这就是努力的意义。

等  级
排  名 1157
经  验 3148
参赛次数 0
文章发表 23
年  龄 0
在职情况 学生
学  校 北邮
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

    #include<stdio.h>

    #include<string.h>


    //反转数组

    void reverseArray(char* a, int start, int end)

    {

        int temp;

        while (start < end)

            {

                temp = a[start];

                a[start] = a[end];

                a[end] = temp;

                start++;

                end--;

            }

    }

    int main()

    {

                char a[100];

                gets(a);

                int len = strlen(a);

                //反转大小写

                for (int i = 0; i < len; i++)

                    {

                        if (a[i] >= 'A' && a[i] <= 'Z')

                            a[i] = a[i] + 'a' - 'A';

                        else

                            a[i] = a[i] + 'A' - 'a';

                    }

                //逆序存储

                reverseArray(a, 0, len - 1);

                //移动数组(向右移动3个位置)

                for (int i = 0;i < len; i++)

                {

                    if (a[i] >= 'A' && a[i] <= 'Z')

                         {

                                if (a[i] >= 'A' && a[i] < 'X')

                                    a[i] = a[i] + 3;

                                else

                                    a[i] = a[i] - 'X' + 'A';

                        }

                    else

                        {

                                if (a[i] >= 'a' && a[i] < 'x')

                                a[i] = a[i] + 3;

                                else

                                a[i] = a[i] - 'x' + 'a';

                        }

                }

                for (int i = 0; i < len; i++)

                    {

                        printf("%c", a[i]);

                    }

            return 0;

    }



 

0.0分

1 人评分

  评论区

  • «
  • »