Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么会RE啊?找了好久了,哪个大牛帮我看看啊!(附代码)

Posted by hezhenbin at 2008-10-17 10:52:25 on Problem 1589
#include<stdio.h>
#include<string.h>
#include <stdlib.h>

char s[105][65];
int cmp(const void *a,const void *b)
{
     return(strcmp((char*)a,(char*)b));
}

				
int main()
{
	int b,i,j,k,n,max,ii,bb,kk;
	while(scanf("%d",&n)!=EOF)
	{
		getchar();
		b=0;
		for(i=0;i<n;i++)
		{
			gets(s[i]);
			k=strlen(s[i]);
			if(b<k) b=k;
		}
		b+=2;
		qsort(s,n,sizeof(s[0]),cmp);
		kk=(int)60/b;
		ii=n/kk;
		if(ii*k<n)
			ii++;
		printf("------------------------------------------------------------\n");
		for(i=0;i<ii;i++)
			for(j=0;j<kk;j++)
			{
				printf("%s",s[i+j*ii]);
				if((i+j*ii)==n-1)
				{
					printf("\n");
					break;
				}
				if(j<kk-1)
				{
					bb=strlen(s[i+j*ii]);
					bb=b-bb;
					for(k=0;k<bb;k++)
						printf(" ");
				}
				else printf("\n");
			}
	}
	return 0;
}



Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator