| ||||||||||
| 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 | |||||||||
小菜鸟求助!没见过的错误………………#include<iostream.h>
#include<stdio.h>
int main()
{
int n,i,j,temp;
cin>>n;
char **tel;
tel=new char*[n];
for(i=0;i<n;i++)
tel[i]=new char[8];
long int *num=new long int[n];
for(i=0;i<n;i++)num[i]=0;
for(i=0;i<n;i++)
for(j=0;j<7;j++)
{
cin>>tel[i][j];
if(tel[i][j]=='-'){j--;continue;}
else if((tel[i][j]<'Q')&&(tel[i][j]>='A'))temp=(tel[i][j]-'A')/3+2;
else if((tel[i][j]>'Q')&&(tel[i][j]<'Z')) temp=(tel[i][j]-'A'-1)/3+2;
else temp=(tel[i][j]-'0');
num[i]=num[i]*10+temp;
}
void qusort(long int a[],int n);
qusort(num,n);
int *r=new int[n];
for(i=0;i<n;i++)
r[i]=0;
for(i=0;i<n-1;i++)
if(num[i]==num[i+1])
{ r[i]=1;
for(j=i;(j<n-1)&&num[j]==num[j+1];j++)
r[i]++;
i=i+r[i]-1;
}
if(n==1) ;
else
for(i=0;i<n-1;i++)
{if(r[i]==0)continue;
else
{
printf("%d-%d %d\n",num[i]/10000,num[i]%10000,r[i]);
i=r[i]+i-1;
}
}
for(i=0;i<n;i++)
{
if(r[i]==0)continue;
else break;
}
if(i==n)cout<<"No duplicates."<<endl;
return 0;
}
int par(long int*a,int low,int high)
{
long int t;
while(low<high){
while(low<high&&a[high]>=a[low])
high--;
t=a[high];
a[high]=a[low];
a[low]=t;
while(low<high&&a[high]>=a[low])
low++;
t=a[high];
a[high]=a[low];
a[low]=t;
}
return low;
}
void qsort(long int*a,int low,int high)
{
if(low<high)
{int piv=par(a,low,high);
qsort(a,low,piv-1);
qsort(a,piv+1,high);
}
}
void qusort(long int*a,int n)
{
qsort(a,0,n-1);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator