Try
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<int,int> mymap;
for(int i=0;i<10;i++)
{
int p;
cin >> p;
if ( mymap.find(p) != mymap.end())
++mymap[p];
else
mymap[p] = 1;
}
for ( const auto & item : mymap)
{
if ( item.second == 1)
cout << item.first << " ";
}
cout << endl;
return 0;
}
[update]
If you have an outdated
C++
compiler then try the following code:
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<int,int>mymap;
for(int i=0;i<10;i++)
{
int p;
cin >> p;
if ( mymap.find(p) != mymap.end())
++mymap[p];
else
mymap[p] = 1;
}
for ( map<int,int>::iterator it = mymap.begin(); it != mymap.end(); ++it)
{
if ( it->second == 1)
cout << it->first << " ";
}
cout << endl;
return 0;
}
[/update]