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

来源:互联网 发布:json数组解析 编辑:程序博客网 时间:2024/05/29 09:04
#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;}

0 0
原创粉丝点击