您的位置:首页 > 编程语言 > C语言/C++

C++ Primer第四版习题--3.10

2015-05-06 10:13 239 查看
#include <iostream>
#include <string>
#include <cctype>

int main()
{
std::string str, result_str;
bool flag=false;
while(getline(std::cin, str))
{
for(unsigned index=0; index<str.size(); ++index)
{
char ch;
ch = str[index];
if(ispunct(ch))
flag = true;
else
result_str += ch;
}
if(flag)
std::cout << result_str << std::endl;
else
std::cout << "no flag" << std::endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: