Mail Archives: djgpp/2002/12/07/15:15:19
From: | "Pohihihi" <pohihihi AT hotmail DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | help needed
|
Lines: | 101
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 6.00.2800.1106
|
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2800.1106
|
Message-ID: | <busI9.99733$2z1.28005485@twister.socal.rr.com>
|
Date: | Sat, 07 Dec 2002 20:03:19 GMT
|
NNTP-Posting-Host: | 66.8.234.241
|
X-Complaints-To: | abuse AT rr DOT com
|
X-Trace: | twister.socal.rr.com 1039291399 66.8.234.241 (Sat, 07 Dec 2002 12:03:19 PST)
|
NNTP-Posting-Date: | Sat, 07 Dec 2002 12:03:19 PST
|
Organization: | RoadRunner - West
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
sorry if this is the wrong newsgroup
hey, i don't have much idea about C/C++ programming, i am more into java, i
got this code which was written in borland (atleast i think so) and i am
interested in seeing what it does (but i have an idea about it). i am giving
the whole code below which is creating problem [lost of error all kind of].
please have a look and let me know what is the problem as the files are all
related to borland (if i understand it correctly). i tried to run it on
MS-VC6++ but same story. i wish the coder must have given the compiler name
used. thanks
--
pohihihi
//////////////////////////////////////////////////////
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
float LineEq(int a, int b, float t)
{
return(a+t*(b-a));
}
void DrawKoch(int x1, int y1, int x5, int y5, float alpha, int level)
{
int x2,y2, x3,y3, x4,y4;
int xc,yc;
int xt,yt;
float factor1, factor2, factor3;
factor1 = 0.5-alpha/2;
factor2 = 0.5+alpha/2;
factor3 = 1.732*alpha;
x2 = LineEq(x1, x5, factor1);
y2 = LineEq(y1, y5, factor1);
x4 = LineEq(x1, x5, factor2);
y4 = LineEq(y1, y5, factor2);
xc = LineEq(x1, x5, 0.5);
yc = LineEq(y1, y5, 0.5);
xt = (y5-yc)+xc;
yt = -(x5-xc)+yc;
x3 = LineEq(xc, xt, factor3);
y3 = LineEq(yc, yt, factor3);
if (level==0)
line(x1,y1,x5,y5);
else if (level==1)
{
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x4,y4);
line(x4,y4,x5,y5);
}
else
{
DrawKoch(x1,y1,x2,y2,alpha,level-1);
DrawKoch(x2,y2,x3,y3,alpha,level-1);
DrawKoch(x3,y3,x4,y4,alpha,level-1);
DrawKoch(x4,y4,x5,y5,alpha,level-1);
}
}
void InitGraph()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
}
void main(int argc, char *argv[])
{
int xmax, ymax, color;
if (argc<7)
{
printf("Syntax: koch x1 y1 x2 y2 alpha level\n\n");
exit(1);
}
InitGraph();
setcolor(getmaxcolor());
DrawKoch(atoi(*(argv+1)),atoi(*(argv+2)),atoi(*(argv+3)),atoi(*(argv+4)),
atof(*(argv+5)),atoi(*(argv+6)));
getch();
closegraph();
}
- Raw text -