zoukankan      html  css  js  c++  java
  • c语言 11-4

    1、

    #include <stdio.h>
    
    void put_string(const char *s)  // 传入的实参为指针,在数组中,指向首个字符的指针的行为和数组本身一样。
    {
        printf("%s
    ", s);    // 显示数组本身。
    } 
    
    int main(void)
    {
        char str[128] = "abcd";
        
        put_string(str); //实参为字符串名,也就是数组名, 数组名解释为指向数组的第一个元素的指针, 该指针的行为和数组本身一样。
        
        return 0;
    }

    2、

    #include <stdio.h>
    
    void put_s(const char *s)
    {
        printf("%s
    ", s);
    }
    
    int main(void)
    {
        char *str = "abcde";
        
        put_s(str);
        
        return 0;
    }

    3、

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

    4、

    #include <stdio.h>
    #include <string.h>
    
    void put(const char *x)
    {
        int i;
        int len;
        len = strlen(x);
        
        for(i = 0; i < len; i++)
        {
            printf("%c", *x++);
        }
    }
    
    int main(void)
    {
        char str[128] = "abcde";
        
        put(str);
        
        return 0;
    }

    5、

    #include <stdio.h>
    #include <string.h>
    
    void put_s(const char *x)
    {
        int  i;
        int len = strlen(x);
        for(i = 0; i < len; i++)
            putchar(*x++);
    }
    
    int main(void)
    {
        char str[128] = "abcdef";
        
        put_s(str);
        
        return 0;
    }

    6、

    #include <stdio.h>
    
    void put(const char *x)
    {
        while(*x)
            printf("%c", *x++);
    }
    
    int main(void)
    {
        char str[128] = "abcdef";
        
        put(str);
        
        return 0;
    }

  • 相关阅读:
    266. Palindrome Permutation
    265. Paint House II
    264. Ugly Number II
    263. Ugly Number
    261. Graph Valid Tree
    260. Single Number III
    259. 3Sum Smaller
    pthon 批量压缩当前目录,子目录下图片
    不小心打开了N多的压缩文件窗口,一句命令就搞定!
    # Writing your-first Django-app-part 4-simple-form
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14832118.html
Copyright © 2011-2022 走看看