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 cttustc at 2011-10-21 20:24:19
#include<stdio.h>
#include<string.h>

long b[10001]={0};
char phone[10002][2000]={0}; 
long pos[10];

void Qsort(long begin,long end,char str[][2000])
{
	long i=begin,j=end;
	char t[2000],mid[2000];
	strcpy(mid,str[(begin+end)/2]);
	do 
	{
		while (strcmp(str[i],mid)<0) i++;
		while (strcmp(str[j],mid)>0) j--;
		if (i<=j)
		{
		strcpy(t,str[i]);
		strcpy(str[i],str[j]);
		strcpy(str[j],t);
		i++;j--;
		}
	}while (i<=j);
	if (i<end) Qsort(i,end,str);
	if (j>begin) Qsort(begin,j,str);
}

void work(char str[])
{
	long len=strlen(str),i,flag=0;
	for (i=0;i<len;i++)
    {
		if (str[i]!='-')
		{ 
		if (str[i]>='A'&&str[i]<='C') str[i]='2';
		else if (str[i]>='D'&&str[i]<='F') str[i]='3';
		else if (str[i]>='G'&&str[i]<='I') str[i]='4';
		else if (str[i]>='J'&&str[i]<='L') str[i]='5';
		else if (str[i]>='M'&&str[i]<='O') str[i]='6';
		else if (str[i]>='P'&&str[i]<='S') str[i]='7';
		else if (str[i]>='T'&&str[i]<='V') str[i]='8';
		else if (str[i]>='W'&&str[i]<='Y') str[i]='9';
		flag++;
		pos[flag]=str[i]-'0';
		}
	if (flag==7) break;
	}

}


 


int main()
{
    long i,n,flag=0;


	scanf("%ld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%s",phone[i]);
        work(phone[i]);
		memset(phone[i],0,sizeof(phone[i]));
	phone[i][0]=pos[1]+'0';
	phone[i][1]=pos[2]+'0';
	phone[i][2]=pos[3]+'0';
	phone[i][3]='-';
	phone[i][4]=pos[4]+'0';
	phone[i][5]=pos[5]+'0';
	phone[i][6]=pos[6]+'0';
	phone[i][7]=pos[7]+'0';
	
	}
	// Read IN
    Qsort(1,n,phone);
	for (i=1;i<=n;i++)
	{
		if (strcmp(phone[i],phone[i+1])==0) 
			b[i]=b[i-1]+1;
	}
	for (i=1;i<=n;i++)
		if (b[i]==0&&b[i-1]!=0)
		{
			printf("%s %ld\n",phone[i],b[i-1]+1);
			flag=1;
		}
	if (flag==0) printf("No duplicates\n");

	return 0;
}
RE了已经不知道多少回了,求神牛指教

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