zoukankan      html  css  js  c++  java
  • 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;
    }

  • 相关阅读:
    GLSL
    c++ 的垃圾收集(garbage collector
    ZZ 红黑树,并非想象中的那么复杂
    【转载】我心目中的android机器档次
    代码优化
    qqww
    solve Ax+By+C=0
    the c10k problem
    标 题: 腾讯面试题目(PHP程序员)
    zz 软件开发流程工具一览
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14817442.html
Copyright © 2011-2022 走看看