| ||||||||||
| 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 | |||||||||
求救各位,1002能想到测试都过了,依然WA,大家能帮我看看是哪里有BUG么?感激之至#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
using namespace std;
int L[26] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9,0};
struct telenum
{
char* num;
_int32 times;
};
bool operator< (const telenum a,const telenum b)
{
if( strcmp(a.num,b.num) < 0 )
{
return true;
}
else
{
return false;
}
}
int main()
{
vector<telenum> result;
_int32 N;
char* num = new char[100];
char* temp;
scanf("%I32d",&N);
_int32 i = 0;
while( i < N )
{
memset(num,0,sizeof(char)*100);
scanf("%s",num);
char c;
int len = strlen(num);
_int32 j = 0;
_int32 k = 0;
temp = new char[9];
while( j < len )
{
c = num[j];
if( isalnum(c) )
{
if( isalpha(c) )
{
temp[k] = L[c-'A'] + '0';
}
else
{
temp[k] = c;
}
k++;
if( k == 3)
{
temp[k] = '-';
k++;
}
}
j++;
}
temp[8] = '\0';
j = 0;
while( j < result.size() )
{
if( strcmp(temp,result[j].num) == 0)
{
result[j].times++;
break;
}
j++;
}
if( j >= result.size() )
{
telenum* tn = new telenum();
tn->num = temp;
tn->times = 1;
result.push_back(*tn);
}
else
{
delete[] temp;
}
i++;
}
i = 0;
_int32 cnt = 0;
telenum* TN = new telenum[result.size()];
while( i < result.size() )
{
if( result[i].times > 1 )
{
TN[cnt] = result[i];
cnt++;
}
i++;
}
sort(&TN[0],&TN[cnt]);
i = 0;
while( i < cnt )
{
printf("%s %I32d\n",TN[i].num,TN[i].times);
i++;
}
if( cnt == 0 )
{
printf("No duplicates.\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator