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

哪位高手帮我看看程序啊 缺少快排 我不会用qsort() 谁帮我把qsort()加进去啊

Posted by yanzhengfei at 2009-07-22 16:56:16 on Problem 1002
#include"iostream"
#include<stdlib.h>
using namespace std;

struct S
{
	long x;
	int y;
}s[100001];

void Input(int & d)
{
	int i=1; d=0;char c;
	while(i!=0)
	{
		    scanf("\n%c",&c);
	     	if(c!='-')
			{
				if(c=='A'||c=='B'||c=='C')c=50;
				if(c=='D'||c=='E'||c=='F')c=51;
				if(c=='G'||c=='H'||c=='I')c=52;
				if(c=='J'||c=='K'||c=='L')c=53;
				if(c=='M'||c=='N'||c=='O')c=54;
				if(c=='P'||c=='R'||c=='S')c=55;
				if(c=='T'||c=='U'||c=='V')c=56;
				if(c=='W'||c=='X'||c=='Y')c=57;
			    d=10*d+c-48;
				i=(i+1)%8;
			}
		}	
	
}

int main()
{
	int i,j,flag;
	for(i=0;i<100001;i++)
	{
		s[i].x=-1;
		s[i].y=0;
	}
	int n;
	cin>>n;
	int d,k=0;
	for( j=1;j<=n;j++)
	{
	   Input(d);
	   flag=1;
	   for( i=0;i<=k;i++)
	       if(s[i].x==d) 
		   {
			   s[i].y++;flag=0;break;
		   }
	    if(flag)
		   {
			    s[k].x=d;s[k].y++;k++;
		   }  
	}
	flag=1;
	for(i=0;i<n;i++)
		if(s[i].y!=0&&s[i].y!=1) 
		{
			flag=0;
			printf("%03ld-%04ld %d\n", s[i].x/10000, s[i].x%10000, s[i].y);
		}
    if(flag) cout<<"No duplicates."<<endl;
			
	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