Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  p6.cpp
Language: C/C++
Code:
#include<stdio.h> 
 
#include<graphics.h> 
int main() 

int gm,gr,xwmin,ywmin,xwmax, 
ywmax,xvmin,yvmin,xvmax,yvmax,xw,yw,xv,yv,sx,sy; 
detectgraph(&gm,&gr); 
initgraph(&gm,&gr,NULL); 
printf("Enter the window min coordinate(xwmin,ywmin):\n"); 
scanf("%d%d",&xwmin,&ywmax); 
printf("Enter the window max coordinate(xwmax,ywmax):\n"); 
scanf("%d%d",&xwmax,&ywmax); 
rectangle(xwmin,ywmax,xwmax,ywmin); 
printf("Enter the viewport min coordinate(xvmin,yvmin):\n"); 
scanf("%d%d",&xvmin,&yvmin); 
printf("Enter the viewport max coordinate(xvmax,yvmax):\n"); 
scanf("%d%d",&xvmax,&yvmax); 
sx=(xvmax-xvmin)/(xwmax-xwmin); 
sy=(yvmax-yvmin)/(ywmax-ywmin); 
rectangle(xvmin,yvmax,xvmax,yvmin); 
printf("Enter the point coordinate(xw,yw) in the window:\n"); 
scanf("%d%d",&xw,&yw); 
putpixel(xw,yw,15); 
xv=(sx*(xw-xwmin))+xvmin; 
yv=(sy*(yw-ywmin))+yvmin; 
putpixel(xv,yv,15); 
getch(); 
}
Comments: