| ||||||||||
| 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 | |||||||||
who can help me???it always tells me "runtime erro!!!" ft!!!#include "stdio.h"
#include "string.h"
#include "ctype.h"
char convert(char ch)
{char temp1;
int temp;
temp=ch-65;
if(temp>=0&&temp<=2) temp1='2';
else
if(temp>=3&&temp<=5) temp1='3';
else
if(temp>=6&&temp<=8) temp1='4';
else
if(temp>=9&&temp<=11) temp1='5';
else
if(temp>=12&&temp<=14) temp1='6';
else
if(temp>=15&&temp<=18) temp1='7';
else
if(temp>=19&&temp<=21) temp1='8';
else
if(temp>=22&&temp<=24) temp1='9';
return(temp1);
}
void main()
{
char ch,s[100000][9],ss[100000][8],temp1;
long int total,flag[100000]={0},i,j,k,kk,flag2[100000]={0},ishere=0;
scanf("%ld",&total);
k=0;
while(k<total*7)
{
j=k%7;i=k/7;
ch=getchar();
if((isdigit(ch)||isupper(ch))&&ch!='Q'&&ch!='Z')
{
s[i][j]=ch;
k++;
}
}
for(i=0;i<total;i++) /*convert*/
{
for(j=0;j<99;j++)
{
if(isupper(s[i][j]))
{
temp1=convert(s[i][j]);
ss[i][j]=temp1;
}
else
if(isdigit(s[i][j]))
{
ss[i][j]=s[i][j];
}
} ss[i][7]='\0';
}
for(i=0;i<total;i++) /*sorting*/
for(j=total-2;j>=0;j--)
{
kk=strcmp(ss[j],ss[j+1]);
if(kk>0)
{
for(k=0;k<8;k++)
{
ch=ss[j+1][k] ;
ss[j+1][k]=ss[j][k] ;
ss[j][k]=ch ;
}
}
}
for(i=0;i<total;i++)
{
if(flag2[i]==0)
{
k=flag[i];k++;flag[i]=k;
for(j=i+1;j<total;j++)
{
kk=strcmp(ss[i],ss[j]);
if(kk==0)
{
flag2[j]=1; k=flag[i];k++;flag[i]=k;
}
}
}
}
for(i=0;i<total;i++)
{
if(!flag2[i]&&flag[i]>1)
{
ishere=1;
for(j=0;j<7;j++)
{
printf("%c",ss[i][j]);
if(j==2) printf("-");
}
printf(" %ld",flag[i]);
printf("\n");
}
}
if(ishere==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