代码如下:
#include<iostream>
#include<cstring>
using namespace std;
int sum[10005][57],a[57];//sum存储单词的类型。
char t[10005];
int cmp(int c){
if(c==0)//如果sum为空,则一定要添加单词类型。
return 1;
for(int i=1; i<=c; i++)
for(int j=1; j<=52; j++)
if(sum[i][j]!=a[j])
return 1;
return 0;
}
int main()
{
int n;
cin>>n;
int c=0;
for(int i=1; i<=n; i++){
for(int j=1; j<=52; j++)//归零a数组。
a[j]=0;
scanf("%s",t);
for(int j=0; j<strlen(t); j++){//统计字母出现的次数。
if(t[j]>='a'&&t[j]<='z')
a[t[j]-97+1+26]++;
else a[t[j]-65+1]++;
}
if(cmp(c)==1){//判断单词类型以前是否出现过。
c++;//单词类型数量加1。
for(int j=1; j<=52; j++)
sum[c][j]=a[j];添加单词类型。
}
}
cout<<c;输出单词类型数量。
return 0;
}