C++ 小程序

    #include <cstdio>
    #include <iostream>
    using namespace std;
    int main(){
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);


        string str;
        //while(getline(cin, str)){
        while(cin >> str){ //这个遇见空格会断句
            cout << "* " + str << endl; //写Markdown时将每行前面加上一个星号

            int pos = str.find('+'); //写Markdown时将每行的加号前后加上空格
            cout << str.substr(0, pos) << " + " << str.substr(pos + 1, str.size()) << endl;

        }
        return 0;
    }

你可能感兴趣的:(C++ 小程序)