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:你定义的数组X太小,仔细看题目要求,上限为100000,我试过定义10000都不够,更何况你的1500拉!

Posted by bluetears at 2006-03-16 12:05:28 on Problem 1002
In Reply To:各位牛人帮忙看一下,为啥总是runtime error? Posted by:cpp0600548026 at 2006-03-16 08:55:39
> #include<iostream.h>
> #include<string.h>
> #include<stdlib.h>
> #include<stdio.h>
> 
> char x[1500][21];
> 
> int compare(const void*a,const void*b)
> {
> 	return strcmp((char*) a,(char*) b);
> }
> 
> void main()
> {
> 	int n,i,j=0,k;
> 	int *a,*b;
> 	
> 	cin>>n;
> 	a=new int[n];
> 	b=new int[n];
> 	for(i=0;i<n;i++)
> 	{
> 		a[i]=0;
> 		b[i]=0;
> 	}
> 
>     char temp[21];
> 	for(i=0;i<n;i++)
> 	{
> 		char y[]="00000000";
> 		int m=0;
> 		j=0;
> 		cin>>x[i];
> 		k=strlen(x[i]);
> 		for(j=0;j<k;j++)
> 		{
> 			if(x[i][j]>='0' && x[i][j]<='9')
> 			{
> 			      y[m]=x[i][j];
> 			      m++;
> 			      continue;
> 			}
> 	        else if(x[i][j]>='A' && x[i][j]<='C')
> 			{
> 			     y[m]='2';
> 			     m++;
> 			     continue;
> 			}
> 		    else if(x[i][j]>='D' && x[i][j]<='F')
> 			{
> 			    y[m]='3';
> 			    m++;
> 			    continue;
> 			}
>             else if(x[i][j]>='G' && x[i][j]<='I')
> 			{
> 			     y[m]='4';
> 			     m++;
> 			     continue;
> 			}
>             else if(x[i][j]>='J' && x[i][j]<='L')
> 			{
> 			      y[m]='5';
> 			      m++;
> 			      continue;
> 			}
>             else if(x[i][j]>='M' && x[i][j]<='O')
> 			{
> 			      y[m]='6';
> 			      m++;
> 			      continue;
> 			}
>             else if(x[i][j]>='P' && x[i][j]<='S')
> 			{
> 			      y[m]='7';
> 			      m++;
> 			      continue;
> 			}
>             else if(x[i][j]>='T' && x[i][j]<='V')
> 			{
> 			      y[m]='8';
> 			      m++;
> 			      continue;
> 			}
> 		    else if(x[i][j]>='W' && x[i][j]<='Y')
> 			{
> 			       y[m]='9';
> 			       m++;
> 				   continue;
> 			}
> 		}
> 		y[m]='\0';
> 		strcpy(x[i],y);
> 	}
> 
> 	qsort(*x,n,sizeof(x[0]),compare);
> 	//for(i=0;i<n;i++)
> 	//	cout<<x[i]<<endl;	
>     j=0;
> 	k=0;
> 	//strcpy(x[n],"0000000");
> 	strcpy(temp,x[0]);
> 	for(i=0;i<n;i++)
> 	{
> 		if(strcmp(x[i],temp)==0)
> 		{
> 			a[j]+=1;
> 			b[j]=i;
> 			if((i+1)!=n)
> 			{
> 			    if(strcmp(x[i+1],temp)==0)
> 				    continue;
> 			    else
> 				{
> 					strcpy(temp,x[i+1]);
> 				    j++;
> 				}
> 			}
> 		}
> 	}
> 	for(i=0;i<=j;i++)
> 	{
> 		if(a[i]>1)
> 		{
> 			//change(x[i]);
> 			cout<<x[b[i]][0]<<x[b[i]][1]<<x[b[i]][2]<<"-";
> 			cout<<x[b[i]][3]<<x[b[i]][4]<<x[b[i]][5]<<x[b[i]][6]<<" "<<a[i]<<endl;
> 			k=1;
> 			continue;
> 		}
> 	}
> 	if(k==0)
> 		cout<<"No duplicates."<<endl;
> 	delete []a;
> 	delete []b;
> }
> 
> 	   
> 
> 				

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