Party Games
阿新 • • 發佈:2018-12-12
#include <iostream> #include <string> #include<algorithm> using namespace std; int main() { int T,n,i,j; while(cin>>T&&T) { getchar(); string str[1001]; for(i=0;i<T;i++) getline(cin,str[i]); sort(str,str+T); string a=str[T/2-1]; string b=str[T/2]; string c; n=a.length()<b.length()?a.length():b.length(); j=0; for(i=0;i<a.length()&&i<b.length();i++) { if(a[i]==b[i]) { c+=a[i]; } else { if(i==a.length()-1) { c+=a[i]; } else if(b[i]-a[i]>1||i!=b.length()-1) { c+=(a[i]+1); break; } else { c+=a[i]; for(j=i+1;j<a.length();j++) { if(j==a.length()-1||a[j]=='Z') { c+=a[j]; } else { c+=(a[j]+1); break; } } break; } } } cout<<c<<endl; } }