Using pair in c++

Posted by user1543957 on Stack Overflow See other posts from Stack Overflow or by user1543957
Published on 2012-11-14T16:52:59Z Indexed on 2012/11/14 17:00 UTC
Read the original article Hit count: 169

Filed under:
|
|

Can someone please tell why i am unable to compile the following program

#include<iostream>
#include<string>
#include<cmath>
#include<iostream>
#include<cfloat>
#define MOD 10000009

using namespace std;

double distance(pair<int,int> p1,pair<int,int> p2)
{
    double dist;
    dist = sqrt( (p1.first-p2.first)*(p1.first-p2.first) + (p1.second-p2.second)*(p1.second-p2.second) );
    return(dist);
}

int main()
{
        int N,i,j;
        cin >> N;
        pair<int,int> pi[N];
        for(i=0;i<N;i++)
        {
            cin >> pi[i].first >> pi[i].second;
        }

        for(i=0;i<N;i++)
        {
            cout << pi[i].first << " "<< pi[i].second << endl;
        }

        distance(pi[0],pi[1]); // This line is giving error

    return 0;
}

enter image description here

© Stack Overflow or respective owner

Related posts about c++

Related posts about stl