Results 1 to 9 of 9
Thread: C++, .
Hybrid View
-
28th September 2004 14:57 #1Registered User
Join Date: Dec:2003
Location:
Posts: 4,191
C++, .
() . - C++ , , . , .
: 14 . N (2 < N < 13) , . . , - - .!
, !
-
28th September 2004 15:07 #2
-
28th September 2004 15:46 #3
Last edited by singularity; 12th April 2007 at 12:59. Reason:
ignore list:Java,velio,jaredharet,gochev.george,Nit rogeniumQuis custodiet ipsos custodes?
-
28th September 2004 16:35 #4
( ):
Code:#include <stdlib.h> #include <values.h> #include <stdio.h> #include <conio.h> #include <math.h> const CONTOURSCOUNT=14; const MAXPOINTS=13; struct point { float x; float y; }; struct contour { point Points[MAXPOINTS]; } Contours[CONTOURSCOUNT]; float Length(point a,point b) { return(sqrt(abs((b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y)))); } void RandomInitialize(contour *c, int count) { int i; for (i=0; i<count; i++) { c->Points[i].x = random(MAXINT); c->Points[i].y = random(MAXINT); } } void main() { clrscr(); int n,i,j,k, LongestContourNum=0, MinMidLengthNum=0; float Len, LongestContour=0, MinMidLength=MAXFLOAT; do { printf("\nInput number of points (2 - 13): "); scanf("%d",&n); } while (!((n >= 2) && (n <= MAXPOINTS))); do { printf("How do you want to enter the points?\n"); printf("1. Random\n"); printf("2. Manual\n"); scanf("%d",&i); } while ((i<1) || (i>2)); switch(i) { case 1: { for(j=1; j<=CONTOURSCOUNT; j++) RandomInitialize(&Contours[j], n); break; } case 2: { for (j=1; j<=CONTOURSCOUNT; j++) for (k=1; k<=n; k++) { printf("\nInput contour %d point %d.x: ",j,k); scanf("%f", &Contours[j].Points[k].x); printf("\nInput contour %d point %d.y: ",j,k); scanf("%f", &Contours[j].Points[k].y); } } } for (i=1; i <= CONTOURSCOUNT; i++) { Len = 0; for(k=1; k<n; k++) Len = Len + Length(Contours[i].Points[k], Contours[i].Points[k+1]); printf("\nThe length of contour %d is: %f", i, Len); printf("\nThe middle length of contour's %d segments is: %f", i, Len/n); if (LongestContour<Len) { LongestContour=Len; LongestContourNum=i; } if (MinMidLength > Len/n) { MinMidLength = Len/n; MinMidLengthNum = i; } } printf("\n\nThe longest contour is No:%d, with lenght: %f", LongestContourNum, LongestContour); printf("\nThe Contour with milimal middle segments lenth is No:%d with length: %f", MinMidLengthNum, MinMidLength); return; }
: , !
!
-
29th September 2004 08:22 #5
Last edited by singularity; 12th April 2007 at 12:59. Reason:
ignore list:Java,velio,jaredharet,gochev.george,Nit rogeniumQuis custodiet ipsos custodes?
-
29th September 2004 09:40 #6Registered User
Join Date: May:2004
Posts: 43

delian.- , - -.
-
30th September 2004 17:57 #7Registered User
Join Date: Dec:2003
Location:
Posts: 4,191
. (), .
!
, !
-
5th October 2004 00:13 #8
offtopic:
http://www.gnu.org/fun/jokes/helloworld.html- ( - ), ", , , . ANSI , -. 3 "
.. , .
-
5th October 2004 02:55 #9
Last edited by singularity; 12th April 2007 at 13:00. Reason:
ignore list:Java,velio,jaredharet,gochev.george,Nit rogeniumQuis custodiet ipsos custodes?




Reply With Quote
7th May 2023, 16:02 in PC