| ||||||||||
| 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 | |||||||||
为什么总是runtime error呢?#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct N{
char string[40];
int count;
}N;
void dealtemp(char temp[])
{
char temp1[40];
int i,j=0;
for(i=0;i<40&&j<7;i++){
if(temp[i]=='-')continue;
else {
if(temp[i]<'A')temp1[j]=temp[i];
else if(temp[i]>='A'&&temp[i]<='C')temp1[j]='2';
else if(temp[i]>'C'&&temp[i]<='F')temp1[j]='3';
else if(temp[i]>'F'&&temp[i]<='I')temp1[j]='4';
else if(temp[i]>'I'&&temp[i]<='L')temp1[j]='5';
else if(temp[i]>'L'&&temp[i]<='O')temp1[j]='6';
else if(temp[i]<='S'&&temp[i]>'O')temp1[j]='7';
else if(temp[i]<='V'&&temp[i]>'S')temp1[j]='8';
else if(temp[i]<='Y'&&temp[i]>'V')temp1[j]='9';
j++;
}
}
temp1[j]='\0';
strcpy(temp,temp1);
}
main()
{
int now=-1,total,i,j,range[40],k,m;
N str[1000];
char temp[40];
scanf("%d",&total);
for(i=0;i<40;i++)range[i]=0;
for(m=0;m<total;m++){
scanf("%s",temp);
dealtemp(temp);
if(now==-1){
now++;
range[now]=0;
strcpy(str[0].string,temp);
str[0].count=1;
for(i=1;i<total;i++)str[i].count=0;
}else {
for(i=now;i>=0;i--){
k=strcmp(temp,str[range[i]].string);
if(k==0){
str[range[i]].count++;
break;
}else if(k>0){
strcpy(str[now+1].string,temp);
str[now+1].count++;
for(j=now;j>=i;j--)range[j+1]=range[j];
range[i+1]=++now;
break;
}else if(k<0&&i==0){
strcpy(str[now+1].string,temp);
str[now+1].count++;
for(j=now;j>=i;j--)range[j+1]=range[j];
range[i]=++now;
break;
}
}
}
}
if(now==total-1)
printf("No duplicates");
else {
for(i=0;i<=now;i++){
if(str[range[i]].count==1)continue;
for(j=0;j<7;j++){
if(j==3)putchar('-');
putchar(str[range[i]].string[j]);
}
printf(" %d\n",str[range[i]].count);
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator