#include<stdio.h><br /> #include<graphics.h><br /> #include<dos.h><br /> void matrix(int numc, int numl, int high, int width, int sizec, int sizel, int timedelay, int sizeline)<br /> {<br /> setlinestyle(0,0,sizeline);<br /> for(int i=0;i<=numc;i++)<br /> {<br /> setcolor((i<=7)?i:((i%7==0)?5:i%7));<br /> line(i*sizec,0,i*sizec,high);<br /> delay(timedelay);<br /> }<br /> for(int i=0;i<=numl;i++)<br /> {<br /> setcolor((i<=7)?i:((i%7==0)?5:i%7));<br /> line(0,i*sizel,width,i*sizel);<br /> delay(timedelay);<br /> }<br /> }<br /> void diagonal(int numc, int numl, int high, int width, int sizec, int sizel, int timedelay, int sizeline)<br /> {<br /> setlinestyle(0,0,sizeline);<br /> int xs=0,ys=0,xe=0,ye=0;<br /> for (int i=1;i<=(numl+numc-1);i++)<br /> {<br /> setcolor((i<=7)?i:((i%7==0)?5:i%7));<br /> (xs<numc)?xs++:ys++;<br /> (ye<numl)?ye++:xe++;<br /> line(xs*sizec,ys*sizel,xe*sizec,ye*sizel);<br /> delay(timedelay);<br /> }<br /> xs=numc; ys=0; xe=numc; ye=0;<br /> for (int i=1;i<=(numl+numc-1);i++)<br /> {<br /> setcolor((i<=7)?i:((i%7==0)?5:i%7));<br /> (xs>0)?xs--:ys++;<br /> (ye<numl)?ye++:xe--;<br /> line(xs*sizec,ys*sizel,xe*sizec,ye*sizel);<br /> delay(timedelay);<br /> }<br /> }<br /> main()<br /> {<br /> int numc,numl,width,high;<br /> printf("\t- Kich thuoc cua so (WIDTH x HIGH): "); scanf("%d x %d",&width,&high);<br /> printf("\t- Nhap kich thuoc luoi (ROW x COLUMN): "); scanf("%d x %d",&numl,&numc);<br /> initwindow(width,high);<br /> int sizec=width/numc, sizel=high/numl, time=300, sizeline=3;<br /> matrix(numc, numl, high, width, sizec, sizel, time, sizeline);<br /> diagonal(numc, numl, high, width, sizec, sizel, time, sizeline);<br /> getch();<br /> }
Thứ Ba, 26 tháng 1, 2016
đồ họa c
1/26/2016 06:49:00 CH
No comments
0 nhận xét:
Đăng nhận xét