blob: 44f0f92f06dce60fc7fe8f25dbe33399791ef870 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <iostream>
/*
*
* 3.4
*
*
*/
using std::string;
using std::cout;
using std::cin;
using std::cerr;
using std::clog;
using std::endl;
int main () {
string word1;
string word2;
cin >> word1 >> word2;
if(word1 == word2) {
cout << word1 << " and " << word2 << " are equal! " << endl;
} else if (word1 > word2) {
cout << word1 << " is larger than " << word2 << endl;
} else if (word2 > word1) {
cout << word2 << " is larger than " << word1 << endl;
}
string::size_type w1 = word1.size();
string::size_type w2 = word2.size();
if(w1 == w2) {
cout << word1 << " and " << word2 << " have the same length" << endl;
} else if (w1 > w2) {
cout << word1 << " has a longer length than " << word2 << endl;
} else if (w2 > w1) {
cout << word2 << " has a longer length than " << word1 << endl;
}
return 0;
}
|