Example #1
0
int main()
{
  int tests;
  typedef map<string, int> Numbers;
  string x;
  int n;

  if(scanf("%d\n", &tests));

  for(int t = 0; t < tests; ++t)
  {
    cin >> n;

    Numbers nums;

    for(int i = 0; i < n; ++i)
    {
      cin >> x;
      sanitise(x);

      Numbers::iterator it = nums.find(x);
      if(it == nums.end())
      {
        it = nums.insert(Numbers::value_type(x, 0)).first;
      }
      it->second++;
    }

    Numbers::iterator it = nums.begin();

    bool found = false;

    if(t > 0) printf("\n");

    while(it != nums.end())
    {
      if(it->second > 1)
      {
        printf("%s %d\n", it->first.c_str(), it->second);
        found = true;
      }
      ++it;
    }

    if(!found)
    {
      printf("No duplicates.\n");
    }
  }

  return 0;
}
Example #2
0
void add(int num) {
    numbers.insert(num);        
}