Results 1 to 4 of 4
-
14th May 2011, 08:46 AM #1OPProbation
anyone can write this c++ code.
Given set of points in the plane
1. The minimum distance between two points.
2. The maximum distance between two points.
3. The largest area of a triangle which has vertices at given points.
4. The area of a convex hull of the set of points.
The values should be computed as a number with 5 digits after the decimal point.
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
8 65
63 61
93 79
48 93
8 45
59 54
92 94
47 0
40 65
25 16
24 92
79 35
73 13
41 89
0 86
21 14
74 96
82 15
0 29
20 76
49 36
66 24
84 57
4 38
66 41
53 47
49 20
92 91
86 78
63 64
20 71
24 81
85 39
63 48
Thnx for helpiamuser_2007 Reviewed by iamuser_2007 on . anyone can write this c++ code. Given set of points in the plane 1. The minimum distance between two points. 2. The maximum distance between two points. 3. The largest area of a triangle which has vertices at given points. 4. The area of a convex hull of the set of points. The values should be computed as a number with 5 digits after the decimal point. Rating: 5
-
14th May 2011, 08:49 AM #2Banned
is that your computer homework
-
14th May 2011, 09:01 AM #3OPProbation
i have this code. i am learning cpp.
i am beginner and trying to learn programming
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
struct point
{
int x;int y;
point () {}
point (int a,int b) : x(a) , y(b) {}
friend float dist (point a,point b)
{
int p1; int p2;
(a.x>b.x) ? p1=a.x-b.x : p1=b.x-a.x;
(a.y>b.y) ? p2=a.y-b.y : p2=b.y-a.y;
return sqrt((p1*p1) + (p2*p2));
}
};
struct triangle : public point
{
point a;point b;point c;
triangle (point a1,point b1,point c1) : a(a1) , b(b1) , c(c1){}
float area()
{
return (~( a.x*(b.y-c.y) + b.x*(c.y-a.y) + c.x*(a.y-b.y) ) /2) +1;
}
float perim() {return dist(a,b)+dist(b,c)+dist(a,c);}
};
int main()
{
point a(96,48);
point b(91,94);
point c(77,31);
triangle d(a,b,c);
cout << d.perim() << endl << d.area();
system("pause");
return 0;
}
how to modify this code and how to enter those above list numbers.
-
21st May 2011, 03:14 PM #4Member
I think that's a difficult problem.
With a "naive" algorithm you have:
distances: if you have n points you have to check n? distances/pairs.
area of triangles: if you have n points you have to check n? triangles.
Is a naive algorithm ok? Because anything else:
- beyond my capability
- I don't have the time.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Write For Us
By Kw3rLn in forum Webmaster DiscussionReplies: 0Last Post: 12th May 2012, 04:55 PM -
New Place to write your Name
By Pettrious in forum Useful SitesReplies: 1Last Post: 18th Aug 2011, 07:56 AM -
write your name with blood
By leonight in forum Useful SitesReplies: 5Last Post: 3rd Dec 2010, 02:48 PM -
Write your first C# program!
By iFlames in forum Web Development AreaReplies: 10Last Post: 29th Jun 2010, 05:31 PM -
how do i write?
By lig}{tning in forum vBulletinReplies: 10Last Post: 18th Aug 2009, 08:45 AM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...