#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctype.h>
#include <algorithm>
using namespace std;
char chan[27] = {"22233344455566677778889999"};
//字符变为数字函数
int change(char *str)
{
int sum = 0;
for (int i = 0; i < strlen(str); i++) {
if (isalpha(str[i]))
sum = sum * 10 + chan[str[i] - 'A'] - '0';
else if (isdigit(str[i]))
sum = sum * 10 + str[i] - '0';
}
return sum;
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
int num[100050];
int n, k = 0;
scanf("%d", &n);
getchar();
//输入数据
while (n--) {
char str[200];
gets(str);
num[k++] = change(str);
}
//排序
sort(num, num + k);
int count = 1, count_2 = 0;
for (int i = 0; i < k; i++) {
if (num[i] == num[i + 1]) {
count++, count_2++;
if(i == k-1)
printf("%03d-%04d %d\n", num[i]/10000, num[i]%10000, count);
}
else if (count != 1) {
printf("%03d-%04d %d\n", num[i]/10000, num[i]%10000, count);
count_2++, count = 1;
}
}
if (count_2++ == 0)
printf("No duplicates.\n");
if (t > 0 && t != 0)
printf("\n");
}
return 0;
}
UVA 755 (暑假-排序、检索(2)-D-487--3279 )
最新推荐文章于 2014-07-28 08:51:30 发布