| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1630 人关注过本帖
标题:如何不用string.h函数实现strlen函数?
取消只看楼主 加入收藏
ClearningC
Rank: 2
等 级:论坛游民
帖 子:98
专家分:43
注 册:2016-10-26
结帖率:89.47%
收藏
已结贴  问题点数:20 回复次数:0 
如何不用string.h函数实现strlen函数?
Description:
不使用strlen函数和其他string.h库中的函数,使用两种方法(递归和非递归)实现统计字符串长度的功能。
函数声明为:
递归:
int RecursionLength(char *s)
非递归:
int NoRecursionLength(char *s)
只用提交函数实现,不用提交main函数
Sample Input:
abcdefghi1234567890
Sample Output:
with recursion: 19
without recursion: 19
下面是主函数
程序代码:
#include<stdio.h>
#include<stdlib.h>
int main() {
        int RecursionLength(char *s);
        int NoRecursionLength(char *s);
        char *s;
        s = (char*)malloc(sizeof(char*) * 60);
        scanf("%s", s);
        printf("with recursion: %d\n", RecursionLength(s));
        printf("without recursion: %d\n", NoRecursionLength(s));
        free(s);
        return 0;
}

我看不懂,不会写
搜索更多相关主题的帖子: recursion 字符串 color 如何 统计 
2016-12-12 11:10
快速回复:如何不用string.h函数实现strlen函数?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016914 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved