计算机学院大学生程序设计竞赛(2015’12) 1001 The Country List

#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

char s[100+10][20+10];
int n;
map<string ,int>m;

int main()
{
    while(~scanf("%d",&n)){
    for(int i=0;i<n;i++) scanf("%s",s[i]);
    m.clear();
    for(int i=0;i<n;i++)
    {
        int len=strlen(s[i]);
        for(int j=0;j<len;j++)
        {
            if(s[i][j]>='A'&&s[i][j]<='Z') s[i][j]=s[i][j]-'A'+'a';
        }
    }

  //  for(int i=0;i<n;i++)  printf("%s
",s[i]);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(strlen(s[i])==strlen(s[j]))
            {
                int len=strlen(s[i]);
                int num=0;
                for(int k=0;k<len;k++)
                {
                    if(s[i][k]==s[j][k]) num++;
                }
                if(num>2)
                {
                    if(m[s[i]]==0) ans++;
                    if(m[s[j]]==0) ans++;
                    m[s[i]]=1;
                    m[s[j]]=1;

                }
            }
        }
    }
    printf("%d
",ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/5080465.html