i see this code in this thread, i want to know how to get input by user or from file in this code. for example this list how to use it as input in this code. i don't know how to modify and how to use it.
Daniweb thread reference = http://www.daniweb.com/software-development/cpp/threads/282872
for example this list as input
96 48
91 94
77 31
3 2
68 17
33 9
52 23
99 78
25 63
18 89
98 54
82 64
31 98
99 71
97 36
32 49
#include <iostream>
#include <vector>
#include <math>
using namespace std;
struct point
{
int x;int y;
point () {}
point (int <strong class="highlight"><vb_highlight>a</strong></vb_highlight>,int b) : x(<strong class="highlight"><vb_highlight>a</strong></vb_highlight>) , y(b) {}
friend float dist (point <strong class="highlight"><vb_highlight>a</strong></vb_highlight>,point b)
{
int p1; int p2;
(<strong class="highlight"><vb_highlight>a</strong></vb_highlight>.x>b.x) ? p1=a.x-b.x : p1=b.x-a.x;
(<strong class="highlight"><vb_highlight>a</strong></vb_highlight>.y>b.y) ? p2=a.y-b.y : p2=b.y-a.y;
return sqrt((p1*p1) + (p2*p2));
}
};
struct <strong class="highlight">triangle</strong> : public point
{
point <strong class="highlight"><vb_highlight>a</strong></vb_highlight>;point b;point c;
<strong class="highlight">triangle</strong> (point a1,point b1,point c1) : <strong class="highlight"><vb_highlight>a</strong></vb_highlight>(a1) , b(b1) , c(c1){}
float <strong class="highlight"><vb_highlight>area</strong></vb_highlight>()
{
return (~( <strong class="highlight"><vb_highlight>a</strong></vb_highlight>.x*(b.y-c.y) + b.x*(c.y-a.y) + c.x*(<strong class="highlight"><vb_highlight>a</strong></vb_highlight>.y-b.y) ) /2) +1;
}
float perim() {return dist(<strong class="highlight"><vb_highlight>a</strong></vb_highlight>,b)+dist(b,c)+dist(<strong class="highlight"><vb_highlight>a</strong></vb_highlight>,c);}
};
int main ()
{
point <strong class="highlight"><vb_highlight>a</strong></vb_highlight>(31,21);
point b(23,33);
point c(54,34);
<strong class="highlight">triangle</strong> d(<strong class="highlight"><vb_highlight>a</strong></vb_highlight>,b,c);
cout << d.perim() << endl << d.area();
}
thanks
waiting for replies