编写一个C++程序,从键盘输入3个字符串,在屏幕上输出其中最大者。

如题所述

#include <IOSTREAM>
#include <string>
using namespace std;
string comp (string &s1, string &s2);
int main()
{
string s1, s2, s3, s4;
cout << "请输入第一个字符串:" <<endl;
cin >> s1;
cout << "请输入第二个字符串" <<endl;
cin >> s2;
cout << "请输入第三个字符串" <<endl;
cin >> s3;
s4 = comp(comp(s1,s2), s3);
cout << "最大的字符串为: "<< s4 <<endl;
return 0;
}
string comp (string &s1, string &s2)
{
if (s1 >= s2)
return s1;
else
return s2;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-03-22
int i, j; int flag; int count; char a[SIZE]; char b[SIZE]; char c[SIZE]; char t[SIZE]; printf("请输入3个字符串a,b,c:\\n"); ,
相似回答