#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<iostream.h>
struct s
{
int x,y;
};
void main()
{
int n;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
struct s inp[10],out[10];
printf(" Enter no of
vertices");
scanf ("%d",&n);
for(int i=0;i<n;i++)
{
scanf ("%d",&inp[i].x);
scanf ("%d",&inp[i].y);
}
int tx,ty;
printf("\n Enter the
Transformation value");
scanf ("%d%d",&tx&ty);
for(i=0;i<n;i++)
{
out[i].x=inp[i].x+tx;
out[i].y=inp[i].y+ty;
}
inp[n]=inp[0] ;
out[n]=out[0] ;
for(i=0;i<n;i++)
{
setcolor(7);
line(inp[i].x,inp[i].y,inp[i+1].x,inp[i+1].y);
}
for(i=0;i<n;i++)
{
printf ("%d%d", out[i].x,out[i].y);
}
for(i=0;i<n;i++)
{
setcolor(4);
line(out[i].x,out[i].y,out[i+1].x,out[i+1].y);
}
getch();
closegraph();
}
Thank you so much
ReplyDelete