第13周项目5字符串操作大合并
来源:互联网 发布:请确保已安装填充数据 编辑:程序博客网 时间:2024/06/05 20:18
编号及代码:/**Copyright (c)2014,计算机与控制工程学院*All rights reserved *作者:范星月*完成日期:2014年11月24日*版本号:v1.0**问题描述:按要求完成一连串的操作*问题输入:输入字母*问题输出:输出统计结果*/#include<iostream>#include<cstdio>using namespace std;int main(){char str[50];int i=0,n=0;cout<<"输入字符串:";gets(str);while(str[i]!='\0'){if(str[i]=='A') n++;i++;}cout<<"其中A个数是: "<<n<<endl;return 0;}#include<iostream>#include<cstdio>using namespace std;int main(){char str[50];int i=0,up=0,low=0;cout<<"输入字符串:";gets(str);while(str[i]!='\0'){ if (str[i]>='A'&&str[i]<='Z') up++;else if (str[i]>='a'&&str[i]<='z')low++;i++;}cout <<"大写字母的个数:"<<up<<endl;cout <<"小写字母的个数:"<<low<<endl;return 0;}#include<iostream>using namespace std;int main(){char str[50]={"40650151054630"};int i=0,a[10]={0};for (i=0;str[i]!='\0';i++) { if (str[i]>='0'&&str[i]<='9') a[str[i]-'0']++; }cout <<"\""<<str<<"\"中各数字出现的次数:"<<endl;for (i=0;i<=9;i++)cout <<"\""<<i<<"\'---"<<a[i]<<endl;return 0;}#include<iostream>using namespace std;int main(){char str[50]={"f;kaljtoreijggfjkeas"};int i=0,a[26]={0};for (i=0;str[i]!='\0';i++) { if (str[i]>='a'&&str[i]<='z') a[str[i]-'a']++ ; } cout <<"\""<<str <<"\"中各个字母出现的次数:"<<endl; for (i=0;i<26;i++)cout <<"\'"<<char (i+97)<<"\'---"<<a[i]<<endl;return 0;}
运行结果:
学习总结:学会了统计一个字母出现的次数,统计大小写时用到的if -else if 语句,统计每一个字母出现的次数,很有意思哒
学习心得:一次一次中的进步
0 0
- 第13周项目5字符串操作大合并
- 第13周项目5--合并字符串
- 第13周项目5--字符串操作
- 第13周项目5-字符串操作
- 第13周项目5-字符串操作--字符串复制
- 第13周项目 5.1 字符串操作
- 第13周项目5(1-1)-字符串操作
- 第13周项目5(1-2)-字符串操作
- 第13周项目5(1-3)-字符串操作
- 第13周项目5(1-4)-字符串操作
- 第13周项目5(2-1)-字符串操作
- 第13周项目5(2-2)-字符串操作
- 第13周项目5(2-3)-字符串操作
- 第13周项目5(2-4)-字符串操作
- 第13周项目5-字符串操作(1.2)
- 第13周项目5-字符串操作(2.1)
- 第13周项目5-字符串操作(2.3)
- 第13周项目5-字符串操作(2.2)
- 添加Cygwin桌面右键菜单
- Go内建函数(对于引用类型) new 和 make 的区别
- CMake标准
- ControlPaint.DrawBorder详细参数设置
- asp.net(c#)微信公众平台源码微信运营管理平台微网站微商城源码2014最新版
- 第13周项目5字符串操作大合并
- 软件架构————语句方面注意事项(1)
- 队列 整形数组实现
- HOTween——简单使用
- JDK的目录结构及结构图
- APP推广运营沙龙干货整理
- TextView长按复制实现方法小结
- 自定义控件
- SVN-钩子解释