已AC代码:
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct line
{
char s[30];
int l;
};
bool cmp(const line a, const line b)
{
return a.l < b.l;
}
int main()
{
int n, cont=1;
scanf("%d", &n);
while(n)
{
line a[n], b[n];
for(int i=0; i<n; i++)
{
scanf("%s", a[i].s);
a[i].l = strlen(a[i].s);
}
sort(a, a+n, cmp);
printf("SET %d\n", cont);
for(int i=0, j=n-1, k=0; i<=j; i++, j--)
{
if(i==j)
{
strcpy(b[i].s, a[k].s);
k++;
}
else
{
strcpy(b[i].s, a[k].s);
k++;
strcpy(b[j].s, a[k].s);
k++;
}
}
for(int i=0; i<n; i++)
printf("%s\n",b[i].s);
cont++;
scanf("%d", &n);
}
return 0;
}
2577

被折叠的 条评论
为什么被折叠?



