求助大佬,挖了1组
查看原帖
求助大佬,挖了1组
544977
CPLQWERTY楼主2021/12/29 19:22
#include <bits/stdc++.h>
using namespace std;
int n, cntt = 1, t; 
string tel[100010];
bool flag = false;
int main () {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		string s[2];
		cin >> s[0];
		s[1] = s[0];
		int cnt = 0;
		for (int j = 0; j < s[0].size(); j++) {
			if (s[0][j] != '-') {
				if (s[0][j] == 'A' || s[0][j] == 'B' || s[0][j] == 'C') s[1][cnt++] = '2';
				if (s[0][j] == 'D' || s[0][j] == 'E' || s[0][j] == 'F') s[1][cnt++] = '3';
				if (s[0][j] == 'G' || s[0][j] == 'H' || s[0][j] == 'I') s[1][cnt++] = '4';
				if (s[0][j] == 'J' || s[0][j] == 'K' || s[0][j] == 'L') s[1][cnt++] = '5';
				if (s[0][j] == 'M' || s[0][j] == 'N' || s[0][j] == 'O') s[1][cnt++] = '6';
				if (s[0][j] == 'P' || s[0][j] == 'R' || s[0][j] == 'S') s[1][cnt++] = '7';
				if (s[0][j] == 'T' || s[0][j] == 'U' || s[0][j] == 'V') s[1][cnt++] = '8';
				if (s[0][j] == 'W' || s[0][j] == 'X' || s[0][j] == 'Y') s[1][cnt++] = '9';
				if (s[0][j] >= '0' && s[0][j] <= '9') s[1][cnt++] = s[0][j];
			}
		}
		s[1].replace(cnt, s[0].size() - cnt, "");
		tel[cntt++] = s[1];
	}
	sort(tel + 1, tel + n + 1);
	for (int i = 1; i <= n + 1; i++) {
		if (tel[i] != tel[i - 1]) {
			if (t > 1) printf("%c%c%c-%c%c%c%c %d\n", tel[i - 1][0], tel[i - 1][1], tel[i - 1][2], tel[i - 1][3], tel[i - 1][4], tel[i - 1][5], tel[i - 1][6], t);
			flag = true;
			t = 1;
		} else {
			t++;
		}
	}
	if (!flag) printf("No duplicates.");
	return 0;
}
2021/12/29 19:22
加载中...