Print 2 | C ++ implementation of the approach ; Function to print the coordinates along with their frequency in ascending order ; map to store the pairs and their frequencies ; Store the coordinates along with their frequencies ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void Print ( int x [ ] , int y [ ] , int n ) { map < pair < int , int > , int > m ; for ( int i = 0 ; i < n ; i ++ ) m [ make_pair ( x [ i ] , y [ i ] ) ] ++ ; map < pair < int , int > , int > :: iterator i ; for ( i = m . begin ( ) ; i != m . end ( ) ; i ++ ) { cout << ( i -> first ) . first << " ▁ " << ( i -> first ) . second << " ▁ " << i -> second << " STRNEWLINE " ; } } int main ( ) { int x [ ] = { 1 , 2 , 1 , 1 , 1 } ; int y [ ] = { 1 , 1 , 3 , 1 , 3 } ; int n = sizeof ( x ) / sizeof ( int ) ; Print ( x , y , n ) ; return 0 ; }