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 2992753 at 2009-03-15 13:08:33 on Problem 1002
#include"stdio.h"
#include"string.h"
#define Q 10000
void main()
{int i,n,j,k,c,flag;
struct student{
char p[20];
int a;};
struct student q[Q],ew[Q],*b[Q],*t;
c=1;
scanf("%d",&n);

    for(i=0;i<n;i++)
    {
scanf("%s",ew[i].p);
k=0;
for(j=0;ew[i].p[j]!='\0';j++)
{
	if(ew[i].p[j]!='-')
{
switch(ew[i].p[j])
{case 'A':
case 'B':
case 'C':ew[i].p[j]='2';break;
case 'D':
case 'E':
case 'F':ew[i].p[j]='3';break;
case 'G':
case 'H':
case 'I':ew[i].p[j]='4';break;
case 'J':
case 'K':
case 'L':ew[i].p[j]='5';break;
case 'M':
case 'N':
case 'O':ew[i].p[j]='6';break;
case 'P':
case 'R':
case 'S':ew[i].p[j]='7';break;
case 'T':
case 'U':
case 'V':ew[i].p[j]='8';break;
case 'W':
case 'X':
case 'Y':ew[i].p[j]='9';break;
}
q[i].p[k]=ew[i].p[j];
k++;
}
if(k==3)
{
q[i].p[k]='-';
k++;
}
q[i].p[k]='\0';
}
     }
for(i=0;i<n;i++)
b[i]=&q[i];
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(strcmp(b[i]->p,b[j]->p)>0)
      {t=b[j];
       b[j]=b[i];
        b[i]=t;}
k=0;
for(i=0;i<n-1;)
{flag=0;
c=1;
for(j=i+1;j<n;j++)
if(strcmp(b[i]->p,b[j]->p)==0)
{
flag=1;
c++;
b[i]->a=c;
}
if(flag==1)
{
printf("%s",b[i]->p);
printf(" ");printf("%d\n",b[i]->a);
k++;
}
if(c!=1)
i=i+c;
else
{b[i]->a=c;
i++;}
}
if(k==0)
printf("No duplicates.\n ");
}

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