标点符号的消除及判断有无

来源:互联网 发布:混沌与秩序2卡牌数据库 编辑:程序博客网 时间:2024/04/30 22:01
#include <iostream>#include <string>using namespace std;int main (){string v1,result_str;char xiao;bool has_punct = false;cout << "Enter a string: " << endl;getline(cin,v1);for(string::size_type index = 0; index != v1.size(); ++index){xiao = v1[index];if(ispunct(xiao))has_punct = true;elseresult_str += xiao;}if(has_punct)cout << "结果:" << endl << result_str << endl;//输出的结果中没有标点符号,只有字母,elsecout << "在输入的字符串中没有发现标点符号!" << endl;return 0;}

0 0
原创粉丝点击