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;
    }

  • 相关阅读:
    数据挖掘实践(23):实战-- 建筑能源得分预测报告(一)
    返回闭包
    函数指针
    Rust 中的 Closure
    Moves, copies and clones in Rust
    Rust的闭包类型(Fn, FnMut, FnOne的区别)
    Clone VS Copy
    rust socket
    A simple UNIX socket listener in Rust
    【firecracker】系统启动与epoll事件循环
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14817442.html
Copyright © 2011-2022 走看看