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 _MaxLee at 2008-05-15 22:44:53 on Problem 1002
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>

char D[100000][9];
char str[24];
char conv[26]={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9','9'};

int cmp(const void *elem1,const void *elem2)
{
	return(strcmp((char *)elem1,(char *)elem2));
}

void con(int n)
{
     int i,j;
     i=-1;j=-1;
     while(j<8)
     {
       i++;
      if(str[i]=='-')
           continue;
       j++;
       if(j==3)
       {
               D[n][j]='-';
               j++;
        }
        /*if(str[i]=='A'||str[i]=='B'||str[i]=='C')
			D[n][j]='2';
		if(str[i]=='D'||str[i]=='E'||str[i]=='F')
			D[n][j]='3';
		if(str[i]=='G'||str[i]=='H'||str[i]=='I')
			D[n][j]='4';
		if(str[i]=='J'||str[i]=='K'||str[i]=='L')
	    	D[n][j]='5';
		if(str[i]=='M'||str[i]=='N'||str[i]=='O')
			D[n][j]='6';
		if(str[i]=='P'||str[i]=='R'||str[i]=='S')
			D[n][j]='7';
		if(str[i]=='T'||str[i]=='U'||str[i]=='V')
			D[n][j]='8';
		if(str[i]=='W'||str[i]=='X'||str[i]=='Y')
			D[n][j]='9';*/
		if(str[i]>='A'&&str[i]<='Z')
           D[n][i]=conv[str[i]-'A'];
		D[n][j]=str[i];
        }
        D[n][j]='\0';
        
}

int main()
{
    int i,j,nCases,cs;
    scanf("%d",nCases);
    for(i=0;i<nCases;i++)
    {
      scanf("%s",str);
      con(i);
    }
    qsort(D,nCases,9,cmp);
    cs=1;
    i=0;
    while(i<nCases)
    {
      j=i;
      i++;
      while(i<nCases&&strcmp(D[i],D[j])==0) {i++;}
      if(i-j>1)
      {
               printf("%s %d\n",D[j],i-j);
               cs=0;
      }
    }
      if(cs);
      printf("No duplicates.\n"); 
    getch();
    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