| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1073 人关注过本帖
标题:多个函数的调用
只看楼主 加入收藏
几米的月亮
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2018-4-28
结帖率:33.33%
收藏
已结贴  问题点数:20 回复次数:4 
多个函数的调用
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册

为什么没有结果显示求助求助
搜索更多相关主题的帖子: 多个 函数 调用 结果 显示 
2018-05-08 21:06
自学的数学
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:46
帖 子:967
专家分:4146
注 册:2017-11-15
收藏
得分:0 
请直接复制代码,你这样发图片,别人不好弄啊,朋友。
2018-05-08 21:12
几米的月亮
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2018-4-28
收藏
得分:0 
sorry
#include<stdio.h>
int main()
{
    int letter(char);
    int dight(char);
    int space(char);
    char str[100];
    gets_s(str,100);
    int m, n, z;
    m = letter(str[100]);
    n = dight(str[100]);
    z = space(str[100]);
printf("letter=%d,dight=%d,space=%d", m, n, z);
return 0;

}
int letter(char)
{
    char str[100];
    gets_s(str,100);
    int i = 0,count = 0;
    while (str[i] != '\0')
    {
        if ((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122))
        {
            count++;
        }
        i++;
    }
    return count;
}
int dight(char)
{
    char str[100];
    gets_s(str, 100);
    int i = 0, count = 0;
    while (str[i] != '\0')
    {
        if (str[i] >= 48&&str[i]<=57)
        {
            count++;
        }

        i++;
    }
    return count;
}


int space(char)
{
    char str[100];
    gets_s(str, 100);
    int i = 0, count = 0;
    while (str[i] != '\0')
    {
        if (str[i] == 32)
        {
            count++;
        }

        i++;
    }
    return count;
}
2018-05-08 21:44
nosnoy
Rank: 9Rank: 9Rank: 9
来 自:mcu
等 级:贵宾
威 望:14
帖 子:541
专家分:1178
注 册:2016-9-17
收藏
得分:10 
回复 3楼 几米的月亮
申明函数不是应该在main函数之前吗
你这样不需要传递形参 ,定义全局变量吧
#include<stdio.h>
#include <stdlib.h>
char str[100];
int i = 0,count = 0;
int letter(void);
int dight(void);
int space(void);
int main()
{
   
    gets(str);
    int m, n, z;
    m = letter();
    n = dight();
    z = space();
    printf("letter=%d,dight=%d,space=%d", m, n, z);
    return 0;
  }
int letter(void)
{
    int i = 0,count = 0;
    while (str[i] != '\0')
    {
        if ((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122))
        {
            count++;
        }
        i++;
    }
    return count;
}
int dight(void)
{
     i = 0, count = 0;
    while (str[i] != '\0')
    {
        if (str[i] >= 48&&str[i]<=57)
        {
            count++;
        }

        i++;
    }
    return count;
}


int space(void)
{
     i = 0, count = 0;
    while (str[i] != '\0')
    {
        if (str[i] == 32)
        {
            count++;
        }

        i++;
    }
    return count;
}

[此贴子已经被作者于2018-5-8 23:08编辑过]


穷举是最暴力的美学
2018-05-08 22:49
dzy123
Rank: 8Rank: 8
等 级:蝙蝠侠
威 望:5
帖 子:379
专家分:820
注 册:2013-4-18
收藏
得分:10 
程序代码:
#include<stdio.h>
int letter(char *);
int dight(char *);
int space(char *);
int main()
{
    char str[100];
    gets(str);
    int m=0, n=0, z=0;
    m = letter(str);
   n = dight(str);
  z = space(str);
printf("letter=%d,dight=%d,space=%d", m, n, z);
return 0;

}
int letter(char *str)
{
    int i = 0,count = 0;
    while (str[i])
    {
        if ((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122))
            count++;
       i++;
    }
    return count;
}
int dight(char  *str)
{
    int i = 0, count = 0;
    while (str[i])
    {
        if (str[i] >= 48&&str[i]<=57)
        
            count++;
        

        i++;
    }
    return count;
}


int space(char  *str)
{
    int i = 0, count = 0;
    while (str[i])
    {
        if (str[i] == 32)
        
            count++;
        

        i++;
    }
    return count;


[此贴子已经被作者于2018-5-8 22:57编辑过]

2018-05-08 22:55
快速回复:多个函数的调用
数据加载中...
 
   



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

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