Results 1 to 4 of 4
Thread: C++
Hybrid View
-
9th November 2010 03:17 #1Registered User
Join Date: Jan:2009
Location:
Posts: 16
C++
! C++. :
Enter a circle and a segment line. Check whether the line lies into the circle.
. , ?
, , ...
.Code:#include "ccc_win.h" #include <cmath> int ccc_win_main() { double xc = cwin.get_double("Enter xc: "); double yc = cwin.get_double("Enter yc: "); double r = cwin.get_double("Enter r: "); Point p(xc,yc); cwin << p << Circle(p, r); double x1 = cwin.get_double("Enter x1: "); double y1 = cwin.get_double("Enter y2: "); double x2 = cwin.get_double("Enter x1: "); double y2 = cwin.get_double("Enter y2: "); Line o (Point(x1, y1), Point(x2,y2)); cwin << o; double dist1 = (x1-xc)*(x1-xc) + (y1-yc)*(y1-yc); double dist2 = (x2-xc)*(x2-xc) + (y2-yc)*(y2-yc); if ((r > dist1) and (r > dist2)) cwin << Message (p, "Segment line into the circle"); else cwin << Message (p, "Segment line outside the circle"); return 0; }
-
9th November 2010 08:52 #2SQRT, ..double dist1 = (x1-xc)*(x1-xc) + (y1-yc)*(y1-yc);
double dist2 = (x2-xc)*(x2-xc) + (y2-yc)*(y2-yc);
(=).double dist1 = SQRT[(x1-xc)*(x1-xc) + (y1-yc)*(y1-yc)];
double dist2 = SQRT[(x2-xc)*(x2-xc) + (y2-yc)*(y2-yc)];
, / .if ((r >= dist1) and (r >= dist2))" , , , , ."
-
9th November 2010 14:06 #3Registered User
Join Date: Jan:2009
Location:
Posts: 16
, , ! : )))
-
9th November 2010 15:20 #4Registered User
Join Date: Oct:2003
Location:
Posts: 4,317
, ,




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in