3.2.2练习3.4/3.2.2练习3.5

来源:互联网 发布:印度历史知乎 编辑:程序博客网 时间:2024/05/17 09:26

3.4

#include<iostream>

#include<string>
#include<cctype>

using namespace std;

void main()
{
    cout << "Enter tow string" << endl;
    string s1,s2;
    cin >> s1 >> s2;
    if (s1.size() == s2.size())
        cout << "They are the same long" << endl;
    else if (s1.size() < s2.size())
        cout << s2 <<" is longer" << endl;
    else cout << s1 <<" is longer" << endl;

    cin.get();
    cin.get();

}





3.5

#include<iostream>
#include<string>
#include<cctype>

using namespace std;

void main()
{
    cout << "Enter strings" << endl;
    string s1, s2;
    cin >> s2;
    while (cin >> s1)
        s2 += s1;
    cin.clear();
    cout << s2 << endl;

    cin.get();

}


输入 crtl +Z+回车


原创粉丝点击