poj1002 总是Runtinme error,望各位高手帮忙解决一下
#include<iostream>
#include<string>
using namespace std;
char ch[]="2223334445556667777888999";
char str[100],telephones[10000][9];
int sortchar(int j)
{
int i=-1,k=-1;
while(k<8)
{
i++;
if(str[i]=='-') continue;
k++;
if(k==3)
{
telephones[j][k]='-';
k++;
}
if(str[i]>='A' && str[i]<='Z')
{
telephones[j][k]=ch[str[i]-'A'];
continue;
}
telephones[j][k]=str[i];
}
telephones[j][k]='\0';
return 0;
}
int main()
{
int i,j=0,n,k,w=0;
char a[8];
cin>>n;
while(j<n)
{
cin>>str;
sortchar(j);
j++;
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
w=0;
for(k=0;k<9;k++)
{
if(telephones[i][k]<telephones[j][k]) break;
if(telephones[i][k]>telephones[j][k])
{
w=1;
break;
}
}
if(w==1)
{
for(w=0;w<8;w++)
{
a[w]=telephones[i][w];
telephones[i][w]=telephones[j][w];
telephones[j][w]=a[w];
}
}
}
}
w=0;
for(i=0;i<n;)
{
j=i;
i++;
while(i<n && strcmp(telephones[j],telephones[i])==0) i++;
if(i-j>1)
{
cout<<telephones[j]<<" "<<i-j<<endl;
w=1;
}
}
if(w==0) cout<<"No duplicates.";
return 0;
}