字符串的复制,长度计算,单词反序输出

来源:互联网 发布:c语言中else if的用法 编辑:程序博客网 时间:2024/04/30 03:08
//实现字符串的复制void strcpytwo(char b[],char a[]){    int i = 0;    while (a[i] != '\0'){        b[i] = a[i];        i++;    }}//实现字符串长度的计算int strlentwo(char a[]){    int i = 0;    while (a[i] != '\0') {        i++;    }    return i;}//实现单词的反序输出void antitone(char str[]){    int i = 0;    int count = 0;    int b[20] = {};    while (str[i] != '\0') {        if (str[i] != ' ') {            count ++;            if (str[i + 1] == ' ' || str[i + 1] == '\0') {                b[i] = count;                count = 0;            }        }        i ++;    }    for (int i = 19; i >= 0; i --) {        if (b[i] != 0) {            for (int j = i - b[i] + 1 ;j < i + 1 ; j ++) {                printf("%c",str[j]);            }            printf(" ");        }    }}

0 0
原创粉丝点击