#include <iostream>
#include <vector>
#include <string>
using namespace std;
bool E(vector<string> v) //判断是否按字典排序
{
for (int i = 0; i < v.size() - 1; i++)
{
if (v[i] > v[i + 1])
return false;
}
return true;
}
bool L(vector<string> v) //判断是否按长度排序
{
for (int j = 0; j < v.size() - 1; j++)
{
if (v[j].size() > v[j + 1].size())
return false;
}
return true;
}
int main()
{
vector<string> v;
int n = 0;
cin >> n;
string s;
for (int i = 0; i < n; i++)
{
cin >> s;
v.push_back(s);
}
if (E(v) && L(v))
cout << "both" << endl;
else if (E(v) && !L(v))
cout << "lexicographically" << endl;
else if (!E(v) && L(v))
cout << "lengths" << endl;
else
cout << "none" << endl;
system("pause");
return 0;
}
判定“字典排序”和“长度排序”
最新推荐文章于 2023-03-08 12:58:30 发布