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

为什么wr了呢?

Posted by chuizi_nudt at 2006-05-13 22:10:44 on Problem 1002
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

const char x[]="22233344455566677778889999";
char a[100000],b[8];
int *c;
int n,i,j,k,la,num;
bool flag=true;

int main()
{
	scanf("%d",&n);
	c=new int [n];
	for(i=0;i<n;i++)
	{
		scanf("%s",a);
		k=0;
		la=strlen(a);
		for(j=0;j<la;j++)
		{
			if(a[j]>='A' && a[j]<='Z')
				b[k++]=x[a[j]-'A'];
			else if(a[j]>='0' && a[j]<='9')
				b[k++]=a[j];
		}
		c[i]=atoi(b);
	}
	sort(c,c+n);
	for(i=0;i<n;i++)
	{
		num=1;
		for(j=i+1;j<n && c[i]==c[j];j++)
			num++;
		if(num>1)
		{
			flag=false;
			printf("%d",c[i]/1000000);
			c[i]%=1000000;
			printf("%d",c[i]/100000);
			c[i]%=100000;
			printf("%d-",c[i]/10000);
			c[i]%=10000;
			printf("%d",c[i]/1000);
			c[i]%=1000;
			printf("%d",c[i]/100);
			c[i]%=100;
			printf("%d",c[i]/10);
			c[i]%=10;
			printf("%d %d\n",c[i],num);
		}
		i=j;
	}
	if(flag)
		printf("No duplicates.\n");
	delete [] c;
	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