i want to draw a rectangle inside it a saqure the inside it a trianglet +using bresenham algorithm
the doctor give us this for code triangle i want to change the code (void main ) for rectangle and square bresenham algorithm #include<iostream.h> #include<graphics.h> #include <conio.h> #include <stdlib.h> void BRH(int x1, int y1, int x2,int y2 ,int c ) { int dx,dy,stepx,stepy,ac,x,y; dx=x2-x1; dy=y2-y1; if(dx>0) stepx=1; else stepx=-1; if(dy>0) stepy=1; else stepy=-1; x=x1; y=y1;ac=0; if(abs(dx)>abs(dy)) { putpixel(x,y,c); do { x+=stepx; ac+=abs(dy); if(ac>= abs(dx)) { y+=stepy; ac-=abs(dx); } putpixel(x,y,c); } while((x!=x2)&&(y!=y2)); } else if(abs(dx)<abs(dy)) { putpixel(x,y,c); do { y+=stepy; ac+=abs(dx); if( ac>= abs(dy)) { x+=stepx; ac-=abs(dy); } putpixel(x,y,c); } while((x!=x2)&&(y!=y2)); } } void main() { int driver=DETECT,mode; int x,y,x1,x2,y1,y2,x3,y3,stepx,stepy,ac,dx,dy,c,i; cout<<"x1,y1 x2,y2 ,c\n "; cin>> x1>>y1>>x2>>y2>>x3>>y3>>c; initgraph(&driver,&mode,"c:/turboc3/bgi"); BRH(x1,y1,x2,y2,c); BRH(x1,y1,x3,y3,c); BRH(x2,y2,x3,y3,c); getch(); closegraph();