| ||||||||||
| 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 | |||||||||
sos sos sos sos sos sos 火急!郁闷!超级郁闷!请高人看看为什摸wa,我实在没辙了#include<iostream.h>
#include<stdlib.h>
#include<stdio.h>
struct tel
{
long int num;
char telnum[8];
tel*next;
};
void main()
{
char num[]="2223334445556667777888999";
char*telnum1;
int i=0,j=0;
long int k,k2,k1=0;
tel*head,*ps,*pend,*head1,*head2;
head=new tel;
head->num=1;
ps=head;
pend=head;
head1=head;
pend->next=NULL;
scanf("%d",&k);
k2=k-1;
while(k!=0)
{
telnum1=new char[100];
scanf("%s",telnum1);
while(j<7)
{
if(telnum1[i]>='0'&&telnum1[i]<='9')
{
ps->telnum[j]=telnum1[i];
j++;
}
else if('A'<=telnum1[i]&&telnum1[i]<'Z')
{
ps->telnum[j]=num[telnum1[i]-'A'];
j++;
}
else if('a'<=telnum1[i]&&telnum1[i]<'z')
{
ps->telnum[j]=num[telnum1[i]-'a'];
j++;
}
i++;
}
while(k<=k2)
{
if(atoi(pend->telnum)<atoi(ps->telnum))
{
pend->next=ps;
pend=ps;
pend->next=NULL;
break;
}
else if(atoi(pend->telnum)==atoi(ps->telnum))
{
pend->num++;
delete ps;
break;
}
if(atoi(head->telnum)==atoi(ps->telnum))
{
head->num++;
delete ps;
break;
}
else if(atoi(head->telnum)>atoi(ps->telnum))
{
ps->next=head;
head=ps;
head1=head;
break;
}
while(atoi(head1->telnum)<atoi(ps->telnum))
{
head2=head1;
head1=head1->next;
}
if(atoi(head1->telnum)==atoi(ps->telnum))
{
head1->num++;
head1=head;
delete ps;
break;
}
else if(atoi(head1->telnum)>atoi(ps->telnum))
{
ps->next=head1;
head2->next=ps;
head1=head;
break;
}
}
delete[]telnum1;
ps=new tel;
ps->num=1;
i=0;
j=0;
k--;
}
delete ps;
while(head->next!=NULL)
{
if(head->num!=1)
{ printf("%c%c%c",head->telnum[0],head->telnum[1],head->telnum[2]);
printf("-");
printf("%c%c%c%c %d\n",head->telnum[3],head->telnum[4],head->telnum[5],head->telnum[6],head->num);
k1++;
}
head=head->next;
}
if(head->num==1&&k1==0)
printf("No duplicates.");
else if(head->num!=1)
{
printf("%c%c%c",head->telnum[0],head->telnum[1],head->telnum[2]);
printf("-");
printf("%c%c%c%c %d\n",head->telnum[3],head->telnum[4],head->telnum[5],head->telnum[6],head->num);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator