题目描述:
从键盘上输入3个字符串,求出其中最大者。
输入:
输入3行,每行均为一个字符串。
输出:
一行,输入三个字符串中最大者。
样例输入:
England
China
America
样例输出:
England
实现代码:
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main() {
string str1, str2, str3;
string maxStr;
while(cin >> str1) {
cin >> str2;
cin >> str3;
maxStr = str1;
if(maxStr.compare(str2) < 0) {
maxStr = str2;
}
if(maxStr.compare(str3) < 0) {
maxStr = str3;
}
cout << maxStr << endl;
}
return 0;
}