chapter 4 第二部分
来源:互联网 发布:淘宝怎么上食用农产品 编辑:程序博客网 时间:2024/04/27 10:42
课本习题4
#include <iostream>#include <iomanip>using namespace std;int main (){char a[100]; int i,daxie,xiaoxie,space,number,other;cout<<"请输入字符长度小于100的文字:";cin.get(a,100);cout<<"the length of string is "<<strlen(a)<<endl;for(i=0;i<100;i++){if (a[i]>='A'&&a[i]<='Z')daxie++;else if(a[i]>='a'&&a[i]<='z')xiaoxie++;else if(a[i]>='0'&&a[i]<='9')number++;else if(a[i]==' ')space++;else if (a[i]=='\0')other=strlen(a)-daxie-xiaoxie-number-space;}cout<<"其中大写字母的个数为:"<<daxie<<endl;cout <<"其中小写字母的个数为:"<<xiaoxie<<endl; cout<<"其中数字的个数为:"<<number<<endl;cout<<"其他字符的个数为:"<<other<<endl;cout<<"空格的个数为:"<<space<<endl;return 0;}习题五:
#include <iostream>#include <iomanip>using namespace std;int main (){char str[100]; cout<<"please input string:";cin.get(str,100);cout<<"字符串"<<str<<"的反向字符串为:\n";for(int i =strlen(str)-1;i>=0;i--)cout<<str[i];cout<<"the length of string"<<str<<"is"<<strlen(str)<<endl;return 0;}
#include <iostream>#include <iomanip>using namespace std;int main (){char a[100],b[100];int i,j=0; cout<<"please input string:";cin.get(a,100);for(i=0;i<100;i++){if(a[i]>='0'&&a[i]<='9')continue;b[j]=a[i];j++;}b[j]='\0';cout<<"删除数字后的字符串为:"<<b<<endl;cout<<"字符串的长度为:"<<j<<endl;return 0;}
0 0
- chapter 4 第二部分
- chapter 3(第二部分)
- chapter 4第一部分
- 《C++捷径教程》读书笔记--Chapter 4--程序控制语句(第二部分)
- 《C++捷径教程》读书笔记--Chapter 6--指针(第二部分)
- 《C++捷径教程》读书笔记--Chapter 11--类(第二部分)
- Scala Cookbook翻译 Chapter 1.Strings 第二部分
- Scala Cookbook翻译 Chapter 2.Numbers 第二部分
- Scala Cookbook读书笔记 Chapter 3.Control Structures 第二部分
- Scala Cookbook读书笔记 Chapter 4.Classes and Properties 第二部分
- 《C++捷径教程》读书笔记--Chapter 7--函数,第一部分:基础知识(第二部分)
- 《C++捷径教程》读书笔记--Chapter 5--数组和字符串(第二部分)
- 《C++捷径教程》读书笔记--Chapter 8--函数,第二部分:引用,重载和默认参数
- 《C++捷径教程》读书笔记--Chapter 9--更多的数据类型与运算符(第二部分)
- 犀牛书第五版读书笔记——Chapter 9. Classes, Constructors, and Prototypes(第二部分)
- 犀牛书第五版读书笔记——Chapter 13. JavaScript in Web Browsers(第二部分)
- 犀牛书第五版读书笔记——Chapter 14. Scripting Browser Windows(第二部分)
- 犀牛书第五版读书笔记——Chapter 15. Scripting Documents(第二部分)
- 微信商城 开发的准备工作
- Lua中的table函数库
- cocos2d-x json解析 jsonBox
- 微信支付告警通知接口与维权接口
- hsv彩色空间的几何基本模型是如何组建起来的
- chapter 4 第二部分
- Java4Android学习笔记
- ios 常见错误收集
- Java中的CopyOnWrite容器
- 正则表达式30分钟入门教程
- HDU 1059 背包
- word 生成目录
- C语言学习(1)---Gcc介绍及编译
- win中 TortoiseSVN使用简介