只需要使用map<string,int>即可。
对于新输入的string,通过map.find或者map.count判断是否在map中,若在,让key++,否则设置key=1
注意map的插入操作
//重复局面
//试统计每个局面分别是第几次出现。
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main()
{
map<string, int> m;
int n;
cin>>n;
for(int i = 0; i<8*n; i++){
string s = "";
for(int j = 0; j<8; j++){
char c;
cin>>c;
s+=c;
}
if(m.find(s)==m.end()){ //或者m.count(s) == 0
// m.insert(map<string, int>::value_type (s, 1));//map插入字符串
m[s] = 1;
}else{
m[s]++;
}
if(i%8==0)
cout<<m[s]<<endl;
}
return 0;
}