• c语言 9-12


    1、

    #include <stdio.h>
    
    void rev(char x[][128], int n)
    {
        int i;
        for(i = 0; i < n; i++)
        {
            int len = 0;
            while(x[i][len])
                len++;
            int j = 0;
            while(x[i][j])
                putchar(x[i][len - 1 - j++]);
            putchar('
    ');
        }
    }
    
    int main(void)
    {
        char str[][128] = {"SEC","ABC"};
        rev(str, 2);
        return 0;
    }

    2、

    #include <stdio.h>
    
    int prin(char x[][128], int n)
    {
        int i;
        for(i = 0; i < n; i++)
        {
            int j = 0;
            while(x[i][j])
                j++;
            while(j--)
                putchar(x[i][j]);
            putchar('
    ');
        }
    }
    
    int main(void)
    {
        char str[][128] = {"abcd", "xyzop"};
        prin(str, 2);
        return 0;
    }

    3、

    #include <stdio.h>
    
    void pri(char x[][128], int n)
    {
        int i;
        char tmp[n][128];
        for(i = 0; i < n; i++)
        {
            int len = 0;
            while(x[i][len])
                len++;
            int j = 0;
            while(x[i][j])
            {
                tmp[i][j] = x[i][len - 1 - j];
                j++;    
            } 
        }
        for(i = 0; i < n; i++)
        {
            int k = 0;
            while(x[i][k])
            {
                x[i][k] = tmp[i][k];
                k++;
            }
        }
        for(i = 0; i < n; i++)
        {
            printf("%s
    ", x[i]);
        }
    }
    
    int main(void)
    {
        char str[][128] = {"abcd", "xyz"};
        pri(str, 2);
        return 0;
    }

    4、

    #include <stdio.h>
    
    void prin(char x[][128], int n)
    {
        int i, j;
        for(i = 0; i < n; i++)
        {
            int len = 0;
            while(x[i][len])
                len++;
            for(j = 0; j < len / 2; j++)
            {
                int tmp = x[i][j];
                x[i][j] = x[i][len - 1 - j];
                x[i][len - 1 - j] = tmp;
            }
        }
        for(i = 0; i < n; i++)
        {
            printf("%s
    ", x[i]);
        }
    }
    
    int main(void)
    {
        char str[][128] = {"abcd","mnop","123456"};
        prin(str, 3);
        return 0;
    }

    5、

    #include <stdio.h>
    
    void print(char x[][128], int n)
    {
        int i;
        char tmp[n][128];
        for(i = 0; i < n; i++)
        {
            int len = 0;
            while(x[i][len])
                len++;
            int j = 0;
            for(j = 0; j < len; j++)
            {
                tmp[i][j] = x[i][len - 1 - j];
            }
            for(j = 0; j < len; j++)
            {
                x[i][j] = tmp[i][j];
            }
        }
        for(i = 0; i < n; i++)
        {
            printf("%s
    ", x[i]);
        }
    }
    
    int main(void)
    {
        char str[][128] = {"abcde", "mnopq", "12345678"};
        print(str, 3);
        return 0;
    }

  • 相关阅读:
    策略思维模式
    初学者之心
    《计算机思维》笔记
    通才论
    Shell 脚本中 set ex 命令的作用
    Python—requests模块详解
    SharePoint CSOM 迁移列表项权限
    实践剖析.NET Core如何支持Cookie和JWT混合认证、授权
    面试突击13:方法优先调用可选参数还是固定参数?
    如何构建一个疾病的动物模型? | animal model of disease
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14819402.html
Copyright © 2020-2023  润新知