2016"百度之星"

思路:题目很简单,直接用map记录每个字符串的个数就可以了。记得对每个字符串先sort()。

AC代码:

#include <cstdio>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
const int MAX_N = 44;
char name[MAX_N];
int n;
map<string, int> m;
string s;
int main()
{
	//freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	while(n--)
	{
		scanf("%s", name);
		sort(name, name + strlen(name));
		s = name;
		printf("%d
", m[s]);
		m[s] ++;
	}
	return 0;
}

  

原文地址:https://www.cnblogs.com/sevenun/p/5493155.html