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

哪位牛人能够将本人的这段代码改正过来啊!牛人请!!!!!!!

Posted by wo_top at 2007-11-23 16:27:14 on Problem 1002
#include<stdio.h>
#include<string.h>
unsigned long dou[1000][2];
unsigned long n;
void change(unsigned long i,unsigned long j)
{  unsigned long p;
   p=dou[i][0];
   dou[i][0]=dou[j][0];
   dou[j][0]=p;
   p=dou[i][1];
   dou[i][1]=dou[j][1];
   dou[j][1]=p;
}
int partition(unsigned long m,unsigned long p)
{ unsigned long v=dou[m][0],i=m,j=p;
do{ 
	do {i++;}
	while(dou[i][0]<v);
	do{j++;}
	while(dou[j][0]>v);
	if(i<j)change(i,j);
  
}while(i<j);
  dou[m][0]=dou[j][0];
  dou[j][0]=v;
  return j;
  
}


void quick(unsigned long p,unsigned long q)
{   unsigned long j;
	if(p<q)
{  j=partition(p,q+1);
   quick(p,j-1);
   quick(j+1,q);
}
}


void form(char num[])
{  int len,e=0;
	len=strlen(num);
	for(int r=0;r<len;r++)
	{  
	   if(e==3)num[e++]='-';
		if(num[r]>='A'&&num[r]<='Z'||num[r]>='0'&&num[r]<='9')
	   {if(num[r]=='A'||num[r]=='B'||num[r]=='C')
	     num[r]='2';
	   if(num[r]=='D'||num[r]=='E'||num[r]=='F')
		num[r]='3';
       if(num[r]=='G'||num[r]=='H'||num[r]=='F')
		num[r]='4';
	   if(num[r]=='J'||num[r]=='K'||num[r]=='L')
		num[r]='5';
		if(num[r]=='M'||num[r]=='N'||num[r]=='O')
		num[r]='6';
		if(num[r]=='P'||num[r]=='R'||num[r]=='S')
		num[r]='7';
		if(num[r]=='T'||num[r]=='U'||num[r]=='V')
		num[r]='8';
		if(num[r]=='W'||num[r]=='X'||num[r]=='Y')
		num[r]='9';
		num[e++]=num[r];
	}
	}
	num[e]='\0';
}
void main()
{ char num1[1000][15];
  unsigned long i=0,j,t,k;
  
  
  scanf("%ld",&n);
  
  scanf("%s",num1[i]);
  form(num1[i]);
  for(k=0;k<n;k++)
  { dou[k][0]=0;
    dou[k][1]=k;
  }
  dou[0][0]=1;
  
  i++;
  t=i;
  while(t++<n)
  { scanf("%s",num1[i]);
   
   form(num1[i]);
    for(j=0;j<i;j++)
	{ if(!strcmp(num1[j],num1[i]))
	   {  dou[j][0]++;
	     break;}
	}
	if(j>=i)
	{i++;
	}
	      
  }
  quick(0,n);
  for(k=0;k<n;k++)
   if(dou[k][0]!=0){
  
    printf("%s %ld",num1[dou[k][1]],dou[k][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