666白想了
原题链接:21072.电话号码2025-05-11 12:13:27
发布于:北京
我都写到输出了,告诉我是固定长度?
****长度不超过1000是1000个 - ?
#include <bits/stdc++.h>
using namespace std;
int n, a[256];
struct node{
int cnt = 0;
node* next[10] = {};
};
node* head = new node;
char s[1009];
stack <node*> ans;
int main(){
a['A']=a['B']=a['C']=2;
for(int i=0;i<=9;i++)
a[i+'0']=i;
for(int i='D';i<='Z';i++)
a[i]=a[i-3]+1;
a['S']=7;
a['V']=8;
a['Y']=9;
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%s", s);
int x = 0;
node* now = head;
for(int j = 0; j < s[j];j++){
if(s[j] != '-'){
int tmp = a[s[j]];
if((*now).next[tmp] == NULL){
(*now).next[tmp] = new node;
}
now = (*now).next[tmp];
}
}
if((*now).cnt++ == 1){
ans.push(now);
}
}
if(ans.empty()){
printf("No duplicates.");
return 0;
}
while(!ans.empty()){
ans.top()
}
return 0;
}
这里空空如也
有帮助,赞一个