c语言字符统计(指针),C语言统计字符个数(指针).doc

C语言统计字符个数(指针)C语言统计字符个数(指针)C语言统计字符个数(指针)

0903-统计字符个数(指针)

时间限制:

1000 毫秒

内存限制:

32768 K字节

总提次数:

HYPERLINK "/judge/course/5/judgelist/?problem=903" 689 次

成功提交次数:

HYPERLINK "/judge/course/5/judgelist/?problem=903&result=AC" 455 次

判题规则:

严格比较

问题描述

输入一行字符,统计并输出其中数字字符、英文字母和其它字符的个数。

要求:

1、编写一函数void count(char *s,int *pdigit,int *pletter,int *pother),其中s为输入的字符串,*pdigit, *pletter,*pother分别表示字符串中数字、字母和其他字符的个数。

输入

输入1个字符串。

输出

输出数字、字母和其他字符的个数。每个数后有一空格。

输入样列

wenzhou university 1933

输出样例

4 17 2

出处

ymc

答案:

#include

#include

void count(char s[],int *pdight,int *pletter,int *pother)

{

int n;

int i;

n=strlen(s);

for(i=0;i

{

if(s[i]>=65&&s[i]<=122)

(*pletter)++;

else if(s[i]>=48&&s[i]<=57)

(*pdight)++;

else

(*pother)++;

}

}

int main()

{

char s[100];

int dight=0;

int letter=0;

int other=0;

gets(s);

count(s,&dight,&letter,&other);

printf("%d %d %d \n",dight,letter,other);

return 0;

}

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值