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

我要崩溃了,怎么老是WA啊

Posted by orbpig at 2007-04-20 23:56:59 on Problem 1002
查也查不错什么错误,能不能弄到数据来对比啊
#include <stdio.h>
short table[26] = {
    2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6,
    7, 0, 7, 7, 8, 8, 8, 9, 9,9,0};
unsigned short phonebook[10000000]={0};

int main()
{
	int times;
	short table2[91];
	int index=0;	

    scanf ("%d", &times);

	int tempint;
	int i;
	int j;
	int elem=0;
    for (j = 65; j < 91; ++j) {
		table2[j]=table[j-65];
    }
    for (i = 0; i < times; ++i) {
		char buffer[128];
		
		
		int count=7;
		index=0;
        scanf ("%s", buffer);
		//gets(buffer);
		buffer[127]='\0';
		char *p=buffer;
		bool flag=false;
		while(count>0)
		{
			if(*p=='\0')
			{
				flag=true;
				break;
			}
			tempint=*p;
			if(tempint>64&&tempint<90&&tempint!=81)
			{
				index=index*10;
				index+=table2[tempint];
				count--;

			}else if(tempint>47&&tempint<58)
			{
				index=index*10;
				index+=(tempint-48);
				count--;

			}else
			{
			}
			p++;			
		}
		if(!flag) phonebook[index]++;
    }
	bool result=false;
    for (i = 0; i < 10000000; ++i) {
		
		if(phonebook[i]>1)
		{
			result=true;
			printf("%03d-%04d %d\n",i/10000,i%10000,phonebook[i]);
		}
    }
	if(result==false)
	{
		printf("No duplicates.\n");
	}
	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