PersonalCorpus 版 (精华区)

1163216  Big Guava ... 400 Accepted  (P.E.)
0:00.130 416 2002/10/12 04:27:00.180


void printl(char *s,int l)
{
    printf("%s",s);
    if (l>0) for (int i=strlen(s);i<l;i++) printf(" ");
}

void main()
{
#ifndef ONLINE_JUDGE
    freopen("c:\\0acm\\uva\\input400.txt","r",stdin);
    freopen("c:\\0acm\\uva\\output400_4.txt","w",stdout);
#endif

    char s[100][100],t[100];
    int i,j,k,n,maxl,c,m,a,b;
    int fin;

    while (scanf("%d\n",&n)==1) {
        
printf("------------------------------------------------------------\n")
;
        maxl=0;
        for (i=0;i<n;i++) { gets(s[i]);j=strlen(s[i]); if (j>maxl) 
maxl=j; }
        for (i=0;i<n-1;i++) {
            for (j=i+1;j<n;j++) if (strcmp(s[i],s[j])>0) {
                strcpy(t,s[j]);
                strcpy(s[j],s[i]);
                strcpy(s[i],t);
            }
        }
/*我理解错了也*/
/* thanks to pamws :) */
        c=62/(maxl+2); a=(n+c-1)/c; b=a*c-n;
        for (i=0;i<a-b;i++) {
            for (j=0;j<c-1;j++) printl(s[a*j+i],maxl+2);
            j=c-1; printl(s[a*j+i],60-(c-1)*(maxl+2));
            printf("\n");
        }
        for (i=a-b;i<a;i++) {
            for (j=0;j<c-2;j++) printl(s[a*j+i],maxl+2);
            j=c-2; printl(s[a*j+i],60-(c-2)*(maxl+2));
            printf("\n");
        }
    }
}
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.724毫秒