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

题1002在编译器能通过,但就是提交不上去,能否指点一下.

Posted by hxx at 2007-08-02 15:08:58
#include <iostream>
#include <string>
using namespace std;
void deal(string b[], string a, int p)//变为标准形式
{
	int j=0;
	string c(8, ' ');
	for(int i=0; i<a.length(); i++)
	{
		if(a[i]>='0'&&a[i]<='9')
			c[j++]=a[i];
		else if(a[i]>='A'&&a[i]<='O')
			c[j++]=(a[i]-'A')/3+2+'0';
		else if(a[i]>='R'&&a[i]<='Y')
			c[j++]=(a[i]-'A'+2)/3+1+'0';
		else if(a[i]=='P')
			c[j++]='7';
		if(j==3)
			c[j++]='-';
	}
	b[p]=c;
}
void insert(string b[], string a, int c[], int &m)//插入并排序
{
	int i;
	if(m==0)
	{
		b[0]=a;
		c[0]=1;
	}
	else {
		for(i=0; i<m; i++)
		{
			if(b[i]==a)
			{
				c[i]++;
				return ;
			}
			else if(b[i]>a)
				break;
		}
		for(int j=m-1; j>=i; j--)
		{
			b[j+1]=b[j];
			c[j+1]=c[j];
		}
		b[i]=a;
		c[i]=1;
	}
	m++;
}
int main()
{
	int c[100], N, j, sign;
	string a[100], b[100];
	while(cin>>N)
	{
		j=0;
		sign=0;
		for(int i=0; i<N; i++)
		{
			cin>>a[i];
			deal(a, a[i], i);
			insert(b, a[i], c, j);
		}
		for(int p=0; p<j; p++)
		{
			if(c[p]>1)
			{
				sign=1;
				cout <<b[p]<<" "<<c[p]<<endl;
			}
		}
		if(sign==0)
			cout <<"No duplicates."<<endl;
	}
}



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