| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我这个读文科的也不让过...郁闷啊,本机运行一切正常(10组不同数据检验)
一上提交就运行错误,郁闷.
#define M 20
#include <stdio.h>
main()
{
char tel[M][16],std[M][8],temp[8];
char cgetnum;
int i,j,k,cflagint,n,tempint;
int times[M];
i=j=k=cflagint=0;
printf("Please input number of lines,less than 20:\n");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
scanf("%s",tel[i]);
for(i=0;i<=n-1;i++)
times[i]=1;
/* first part of the program,will have a testing sentence to verify*/
/*for (i=0;i<=n-1;i++)
printf("%s,%d\n",tel[i],times[i]); */
for(i=0;i<=n-1;i++)
{
for(j=0;tel[i][j]!=0;j++)
{if(tel[i][j]=='-')
continue;
cgetnum=tel[i][j];
/* printf("%c test2\n",cgetnum);*/
if (cgetnum>='A' && cgetnum<='C')
cgetnum='2';
else if(cgetnum>='D' && cgetnum<='F')
cgetnum='3';
else if(cgetnum>='G' && cgetnum<='I')
cgetnum='4';
else if(cgetnum>='J' && cgetnum<='L')
cgetnum='5';
else if(cgetnum>='M' && cgetnum<='O')
cgetnum='6';
else if(cgetnum>='P' && cgetnum<='S')
cgetnum='7';
else if(cgetnum>='T' && cgetnum<='V')
cgetnum='8';
else if(cgetnum>='W' && cgetnum<='Y')
cgetnum='9';
std[i][k]=cgetnum;
/* printf("%c test 3\n",std[i][k]);*/
k++;
}
std[i][k]='\0';
k=0;
}
/* Second part of the program, following a verifying sentence*/
/* for(i=0;i<=n-1;i++)
{ for(j=0;std[i][j]!=0;j++)
printf("%c",std[i][j]);
printf("\n");
} */
for(i=0;i<=n-2;i++)
{if (times[i]==0)
continue;
for(j=i+1;j<=n-1;j++)
{if (times[j]==0)
continue;
if(strcmp(std[i],std[j])==0)
{times[i]=times[i]+1;
times[j]=0;
cflagint=1;
}
}
}
/* Third Part of the Program ,following a verifying sentence*/
/* for (i=0;i<=n-1;i++) printf("times: %d ",times[i]); */
for(i=0;i<=n-2;i++)
for(j=i+1;j<=n-1;j++)
if(strcmp(std[i],std[j])>0)
{strcpy(temp,std[j]);
strcpy(std[j],std[i]);
strcpy(std[i],temp);
tempint=times[i];
times[i]=times[j];
times[j]=tempint;
}
for(i=0;i<=n-1;i++)
if(times[i]>1)
printf("%c%c%c-%c%c%c%c %d\n",std[i][0],std[i][1],std[i][2],std[i][3],std[i][4],std[i][5],std[i][6],times[i]);
if(cflagint==0)
printf("No duplicates.\n");
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator