#include<iostream>
#include<set>
using namespace std;
struct Node
{
int num;
int cls;
};
int main()
{
int m;
cin >> m;
set<int> s1; //存数字
set<int> s2; //存分类
while(m--)
{
s1.clear();s2.clear();
int n;
cin >> n;
Node *p = new Node[n];
for(int i=0;i<n;i++)
{
cin >> p[i].num;
s1.insert(p[i].num);
}
for(int i=0;i<n;i++)
{
cin >> p[i].cls;
s2.insert(p[i].cls);
}
set<int>::iterator it1,it2;
for(it1 = s2.begin();it1!=s2.end();it1++) //打印分类
{
int x = *it1;
cout << x << "={";
int flag = 1;
for(it2 = s1.begin();it2!=s1.end();it2++) //打印数字
{
int count = 0;
for(int i=0;i<n;i++)
{
if(p[i].cls == x && p[i].num == *it2) count++;
}
cout << *it2 << "=" << count;
if(flag < s1.size()) cout <<",";
flag++;
}
cout << "}" << endl;
}
}
return 0;
}
网友评论