计算标点符号
2016-01-11 14:40
253 查看
#include <iostream> #include <string> //#include <ctype.h> //这是标准C语言的头文件, #include <cctype> //C++使用C语言的头文件只要在前面加上c后边的点h省去, using namespace std; int main () { string v1("xiao,, cui !!"); string::size_type punct_cnt = 0; //计数器:标点符号的个数 for(string::size_type index = 0; index != v1.size(); ++index) { if(ispunct(v1[index])) //ispunct(c)是判断字符串是不是标点符号, ++punct_cnt; } cout << "这个字符串里有" << punct_cnt << "个标点符号." << endl; for(string::size_type index = 0; index != v1.size(); ++index) v1[index] = toupper(v1[index]);//toupper(c)是字符变成大写 cout << v1 << endl; return 0; }
相关文章推荐
- Autodesk FBX SDK Program 中文 (二)
- iOS工程通用模块介绍
- JavaScript编码规范[百度]
- gulp安装简介
- linux常用指令
- [HSR算法-Occlusion Culling]
- TCP长连接、短连接
- 不是很爱你
- ImageView设置不可点击无效
- VirtualBox 安装CentOs7后无法联网问题
- 华硕BIOS密码表2002-2011
- Android中visibility属性
- Oracle SQL语句执行步骤
- 从头认识java-17.4 详解同步(1)-由竞争条件引发的问题
- ubuntu14.04LTS编译MUDOS v22.2b14
- 5.5. Dictionaries(字典)
- 明天不是明天
- Mac系统上eclipse+tomcat+mysql环境的搭建
- CentOS 6 rsync 文件同步
- [leetcode oj 83]Remove Duplicates from Sorted List