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 REX at 2005-03-26 15:33:10 on Problem 1002
#include<iostream.h>
#include<math.h>
int change(char *);
struct team
{
    int num;
	int s;
};
void main()
{
	int i,j,k,o=0,temp;
	long t;
	char p[20];
	team *pt;
	cin>>t;
	pt=new team[t];
	for(i=0;i<t;i++)
	{
		pt[i].num=-1;
		pt[i].s=1;
	}
	for(i=0;i<t;i++)
	{
		cin>>p;
		temp=change(p);
		for(j=0;;j++)
		{
			if(temp<=pt[j].num||pt[j].num<0)
			{
				for(k=t;k>j;k--)
					pt[k].num =pt[k-1].num ;
				pt[j].num=temp;
				break;
			}
		}
	}
	for(i=0;i<t;i++)
	{
		for(j=i+1;j<t;j++)
		{
			if(pt[i].num!=pt[j].num)
			{
				i=j-1;
				break;
			}
			pt[i].s ++;
		}
	}
	for(i=0;i<t;i++)
	{
		if(pt[i].s >1)
		{
			j=pt[i].num/10000;
			k=pt[i].num%10000;
			o++;
			cout<<(j<100?"0":"")<<(j<10?"0":"")<<j;
			cout<<'-';
			cout<<(k<1000?"0":"")<<(k<100?"0":"")<<(k<10?"0":"")<<k;
			cout<<" "<<pt[i].s<<endl; 
		}
	}
	if(o==0)
		cout<<"No duplicates."<<endl;
}
int change(char *in)
{
	int out=0;
	int i,j=0;
	for(i=0;j<7;i++)
	{
		if(in[i]<='C'&&in[i]>='A'){out=out+2*int(pow(10,6-j));j++;continue;}
		if(in[i]<='F'&&in[i]>='D'){out=out+3*int(pow(10,6-j));j++;continue;}
		if(in[i]<='I'&&in[i]>='G'){out=out+4*int(pow(10,6-j));j++;continue;}
		if(in[i]<='L'&&in[i]>='J'){out=out+5*int(pow(10,6-j));j++;continue;}
		if(in[i]<='O'&&in[i]>='M'){out=out+6*int(pow(10,6-j));j++;continue;}
		if(in[i]<='S'&&in[i]>='P'){out=out+7*int(pow(10,6-j));j++;continue;}
		if(in[i]<='V'&&in[i]>='T'){out=out+8*int(pow(10,6-j));j++;continue;}
		if(in[i]<='Y'&&in[i]>='W'){out=out+9*int(pow(10,6-j));j++;continue;}
		if(in[i]<='9'&&in[i]>='0'){out=out+(in[i]-'0')*int(pow(10,6-j));j++;continue;}		
	}
	return out;
}

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