#include #include #include "project.h" int main (int argc, char *argv[]) { char c; int i,j; int dir; int n; int p =1; //defaults dir = 2; i = 3600; j = 4800; n = 10; //get command line arguments GET_ARG(n,1) GET_ARG(dir,2) //pring xfig file header printf("#FIG 3.2\nLandscape\nCenter\nInches\nLetter\n100.00\nSingle\n-2\n1200 2\n"); //declare a polyline printf("2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 %i\n\t ",n); //starting point printf("%i %i ",i,j); while ( TRUE ) { //draw a line segment switch(dir){ case 0: i+=DRAGON_LENGTH2; break; case 1: j+=DRAGON_LENGTH2; break; case 2: i-=DRAGON_LENGTH2; break; default: j-=DRAGON_LENGTH2; break; } printf("%i %i ",i,j); p++; //read stdin until end of line reached if ((c = getchar() ) == '\n' ) break; dir = (dir + (c == A ? 1 : -1 ) +4) % 4; //+4 is to stop it going -ve } printf("\n"); fprintf(stderr,"%i lines drawn\n",p); return(EXIT_SUCCESS); }