#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[55] = {},b[55] = {} ;
while(cin >> a && cin >> b)
{
///方式一
int len = max(strlen(a), strlen(b));
bool flag = 1;
for(int i = 0; i < len; i++)
{
if(a[i] < b[i])
{
cout << a << '\n' << b << '\n';
flag = 0;
break;
}
if(b[i] < a[i])
{
cout << b << '\n' << a << '\n';
flag = 0;
break;
}
if(a[i] == b[i])
continue;
}
if(flag)
cout << "a == b" << '\n';
cout << '\n';
///方式二
if(strcmp(a, b) < 0)
cout << a << '\n' << b << '\n';
if(strcmp(a, b) > 0)
cout << b << '\n' << a << '\n';
if(strcmp(a, b) == 0)
cout << "a == b" << '\n';
cout << '\n';
///方式三(不可取)
if(a < b)
cout << a << '\n' << b << '\n';
if(a > b)
cout << b << '\n' << a << '\n';
if(a == b)
cout << "a == b" << '\n';
}
return 0;
}
字符串升序
最新推荐文章于 2024-09-04 20:43:44 发布