博客
关于我
【C语言】统计字符数
阅读量:681 次
发布时间:2019-03-17

本文共 714 字,大约阅读时间需要 2 分钟。

   
#include
int letter_count=0,num_count=0,other_count=0;//用于统计字符串中字母、数字和其他字符的数量void char_count(char *str){ int i=0; while(*(str+i) != '\0'){ char c = *(str+i); if( c >= '0' && c <= '9') num_count++; else if( (c >= 'A' && c <='Z') || (c >= 'a' && c <= 'z')) letter_count++; else other_count++; i++; }}int main() { char str[50]; gets(str); char_count(str); printf("字母数为:%d\t数字数:%d\t其他字符数为:%d\n",letter_count,num_count,other_count); system("pause"); return EXIT_SUCCESS;}

注:以上代码描述了一个用于统计字符类型的程序,适用于处理字符串中的不同字符分类统计场景。设置三个计数器分别记录字母、数字和其他字符的数量,可根据实际需求进行修改和扩展,支持多种字符分类识别功能。

转载地址:http://yizhz.baihongyu.com/

你可能感兴趣的文章
Powershell DSC 5.0 - 参数,证书加密账号,以及安装顺序
查看>>
PowerShell 批量签入SharePoint Document Library中的文件
查看>>
Powershell 自定义对象小技巧
查看>>
pytorch从预训练权重加载完全相同的层
查看>>
PowerShell~发布你的mvc网站
查看>>
PowerShell使用详解
查看>>
Powershell制作Windows安装U盘
查看>>
powershell命令
查看>>
Powershell如何查看本地公网IP
查看>>
pytorch从csv加载自定义数据模板
查看>>
powershell对txt文件的服务器进行ping操作
查看>>
powershell常用
查看>>
PowerShell操作XML遇到的问题
查看>>
PowerShell攻击工具Empire实战
查看>>
PowerShell攻击工具Nishang实战
查看>>
PowerShell攻击工具PowerSploit实战
查看>>
Powershell管理系列(四)Lync server 2013 批量启用语音及分配分机号
查看>>
PowerShell脚本运行完 不要马上关闭用什么命令可以停留窗口窗口
查看>>
PowerShell远程连接到Windows
查看>>
power(8) identity
查看>>