正在加载图片...
#include <math. h #include display. h struct node struct node sknext struct node creat o i struct node *h, *g, *r; intp[8][2]={100,120,160,50,180,100,200,80,240,160,210,220,170,160,140,1901 setcolor(12) for(i=0;i<7;i++)1ine(p[i][0],p[i][l],p[i+1][0],p[i+1][1]) line(p[o][O],p[0][1],p[7][0],p[7][1] rectangle(120,200,230,70); h=NULL for(i=0; i<8;i+ i g=(struct node *)mallOc (LEN) g->dx=p[i][o] dy=p[i][1] f(h==NULL)h=q else r->next=q r->next=NULL return(h) struct node *bui lx(h, x) struct node *h. {ints[2],j[2] struct node *hh, *p *r, *q int max, min p=h; hh=NULL s[0]=p-dx;s[1]=p->dy; p=p->next while(p!=NULL) (j[0]=x j[1]=s[1]+(p->dy-s[l])*(x-s[0])/(p>dx-s[0]) max-s [0 min=p->dx f (s[o]<p->dx)I max=p->dx in=s[0];} if ((j[OJ>=min)&&(j[O]<=max)) i g=(struct node *)malloc(LEN) g->dx=j[O]: q->dy=j[l] if(hh==NULL) hh=g r->next=#include <math.h> #include "display.h" struct node { int dx,dy; struct node *next; }; struct node *creat() { struct node *h,*q,*r; int p[8][2]={100,120,160,50,180,100,200,80,240,160,210,220,170,160,140,190}; int i; setcolor(12); for (i=0;i<7;i++) line(p[i][0],p[i][1],p[i+1][0],p[i+1][1]); line(p[0][0],p[0][1],p[7][0],p[7][1]); rectangle(120,200,230,70); h=NULL; for (i=0;i<8;i++) { q=(struct node *)malloc(LEN); q->dx=p[i][0]; q->dy=p[i][1]; if (h==NULL) h=q; else r->next=q; r=q; } r->next=NULL; return(h); } struct node *builx(h,x) struct node *h; int x; {int s[2],j[2]; struct node *hh,*p,*r,*q; int max,min; p=h; hh=NULL; s[0]=p->dx; s[1]=p->dy; p=p->next; while (p!=NULL) { j[0]=x; j[1]=s[1]+(p->dy-s[1])*(x-s[0])/(p->dx-s[0]); max=s[0]; min=p->dx; if (s[0]<p->dx) { max=p->dx; min=s[0]; } if ((j[0]>=min)&&(j[0]<=max)) { q=(struct node *)malloc(LEN); q->dx=j[0]; q->dy=j[1]; if (hh==NULL) hh=q; else r->next=q;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有