CCF 201403-1 reverse number (full score 100)

Just use the map container in STL.

#include<iostream>
#include<map>
#include<math.h>

using namespace std;

int main()
{
    
    
	int n;
	cin >> n;
	map<int, int> m;
	int v;
	for (int i = 0; i < n; i++)
	{
    
    
		cin >> v;
		m[abs(v)]++;
	}
	int counter = 0;
	for (map<int, int>::iterator it = m.begin(); it != m.end(); it++)
	{
    
    
		if (it->second > 1) counter++;
	}
	cout << counter << endl;
	system("pause");
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_27538633/article/details/105777847