• c语言 9-8


    1、

    #include <stdio.h>
    
    void put(char x[])
    {
        int len = 0;
        while(x[len])
            len++;
        while(len-- > 0)
        {
            putchar(x[len]); 
        }
    }
    
    int main(void)
    {
        char str[128];
        printf("str: "); scanf("%s", str);
        put(str);
        return 0;
    }

    2、

    #include <stdio.h>
    
    void put(char x[])
    {
        int len = 0;
        while(x[len])
            len++;
        int i = 0;
        while(x[i])
        {
            putchar(x[len - 1 - i]);
            i++;
        }
    }
    
    int main(void)
    {
        char str[128];
        printf("str:  "); scanf("%s", str);
        put(str);
        return 0;
    }

    3、

    #include <stdio.h>
    
    void put(char x[])
    {
        int len = 0;
        while(x[len])
            len++;
        char tmp[len];
        int i = 0;
        while(x[i])
        {
            tmp[i] = x[len - 1 - i];
            i++;
        }
        
        for(i = 0; i < len; i++)
        {
            x[i] = tmp[i];
        }
        i = 0;
        while(x[i])
            putchar(x[i++]);
    }
    
    int main(void)
    {
        char str[128];
        printf("str: "); scanf("%s", str);
        put(str);
        return 0;
    }

    4、

    #include <stdio.h>
    
    void put(char x[])
    {
        int len = 0;
        while(x[len])
            len++;
        int i;
        for(i = 0; i < len / 2; i++)
        {
            int tmp = x[i];
            x[i] = x[len - 1 - i];
            x[len - 1 - i] = tmp;
        }
        i = 0;
        while(x[i])
            putchar(x[i++]);
    }
    
    int main(void)
    {
        char str[128];
        printf("str: "); scanf("%s", str);
        put(str);
        return 0;
    }

    5、

    #include <stdio.h>
    
    void put(char x[])
    {
        int len = 0;
        while(1)
        {
            if(x[len] == '')
                break;
            len++;
        }
        char tmp[len];
        int i;
        for(i = 0; i < len; i++)
        {
            tmp[i] = x[len - 1 - i];
            putchar(tmp[i]);
        }
    }
    
    int main(void)
    {
        char str[128];
        printf("str: "); scanf("%s", str);
        put(str);
        return 0;
    }

  • 相关阅读:
    php分享三十:php版本选择
    php分享二十九:命名空间
    高性能mysql读书笔记(一):Schema与数据类型优化
    php分享二十八:mysql运行中的问题排查
    php分享二十七:批量插入mysql
    php分享二十六:读写日志
    Python | 一行命令生成动态二维码
    Python-获取法定节假日
    GoLang-字符串
    基础知识
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14817442.html
Copyright © 2020-2023  润新知