#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; struct stu{ int b[100]; char c[100]; int d; }ty[3]; bool cmp2(int a,int b){ return a<b; } bool cmp1(stu a ,stu b ){ return a.d <b.d ; } int main(){ int a=3; while(a--){ cin >> ty[a].c ; } int l[3]; l[0]=strlen(ty[0].c); l[1]=strlen(ty[1].c); l[2]=strlen(ty[2].c); sort(l,l+2,cmp2); int s=l[0]; for(int i=0;i<3;i++){ for(int j=0;j<s;j++){ ty[i].b[j]=ty[i].c[j]-94; for(int z=s;z>0;z--){ ty[i].b[j]*=30; } ty[i].d +=ty[i].b[j]; } } sort(ty ,ty +2,cmp1); cout << ty[0].d <<endl<<ty[1].d <<endl << ty[2].d<<endl; cout << ty[0].c <<endl<<ty[1].c <<endl << ty[2].c; } |
Double click to view unformatted code.