考拉有n个字符串字符串,任意两个字符串长度都是不同的。
#include <iostream>
#include <string.h>
using namespace std;
int main() {
int n;
cin >> n;
int x = 0, y = 0;
char num[100][100];
for (int i = 0; i < n; i++)
cin >> num[i];
//比较两个字符串的长度,不满足顺序性的进行标记,直接break
for (int i = 0; i < n-1; i++) {
if(strlen(num[i]) > strlen(num[i+1])) {
x = 1;
break;
}
}
//比较两个字符串的字典序,不满足顺序性的进行标记,直接break
for (int i = 0; i < n-1; i++) {
if(strcmp(num[i], num[i+1]) > 0) {
y = 1;
break;
}
}
if(x == 1 && y==0)
cout << "lexicographically" << endl;
else if (x == 0 && y == 1)
cout << "lengths" << endl;
else if (x == 0 && y == 0)
cout << "both" << endl;
else
cout << "none" << endl;
return 0;
}