| ||||||||||
| 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 <iostream>
#include <string>
using namespace std;
char map[] = "22233344455566677778889999";
char a[500];
char b[500][10];
int c[500] = {0};
int sum = 0;
int n;
int comp(const void *a, const void *b)
{
return strcmp((char*)a, (char*)b);
}
int main()
{
cin >> n;
int co = 0;
while(n--)
{
cin >> a;
int x = 0, y = 0;
while(a[x] != '\0')
{
if(y == 3)
b[co][y++] = '-';
if(a[x] >= 'A' && a[x] <= 'Z')
b[co][y++] = map[a[x]-'A'];
if(a[x] == '-')
;
if(a[x] >= '0' && a[x] <= '9')
b[co][y++] = a[x];
x++;
}
b[co][y] = '\0';
co++;
}
qsort(b, co, sizeof(b[0]), comp);
for(int i = 0; i < co-1; i++)
{
int k = 0;
for(int j = i+1; j < co; j++)
{
if(strcmp(b[i], b[j]) == 0)
{
c[j] = 1;
k++;
}
}
sum += k;
if(k != 0 && c[i] == 0)
cout << b[i] << " " << k+1 << endl;
}
if(sum == 0)
cout << "No duplicates." << endl;
system("pause");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator