Utility 2

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,xmin,xmax,ymin,ymax,zmin,zmax,x[10],y[10],z[10];
clrscr();
printf("Enter values of xmin,xmax,ymin,ymax,zmin,zmax: ");
scanf("%d%d%d%d%d%d",&xmin,&xmax,&ymin,&ymax,&zmin,&zmax);
printf("Enter the number of points you want: ");
scanf("%d",&n);
printf("Enter Co-ordinates of n points: ");
for(i=0;i<n;i++)
scanf("%d%d%d",&x[i],&y[i],&z[i]);
for(i=0;i<n;i++)
{
if(xmin<x[i] && x[i]<xmax && ymin<y[i] && y[i]<ymax && zmin<z[i] && z[i]<zmax)
printf("[%d %d %d] point is inside the block.\n",x[i],y[i],z[i]);
else if(xmin>x[i] || x[i]>xmax || ymin>y[i] || y[i]>ymax || zmin>z[i] || z[i]>zmax)
printf("[%d %d %d] point is outside the block.\n",x[i],y[i],z[i]);
else
printf("[%d %d %d] point is on the block.\n",x[i],y[i],z[i]);
}
getch();
}

//Output
Enter values of xmin,xmax,ymin,ymax,zmin,zmax: 3
9                                                                            
1                                                                            
5                                                                            
-3                                                                            
8                                                                            
Enter the number of points you want: 6                                        
Enter Co-ordinates of n points: 3 8 5                                        
1 2 3                                                                        
3 1 8                                                                        
4 5 6                                                                        
4 4 4                                                                        
6 3 0                                                                        
[3 8 5] point is outside the block.                                          
[1 2 3] point is outside the block.                                          
[3 1 8] point is on the block.                                                
[4 5 6] point is on the block.                                                
[4 4 4] point is inside the block.                                            
[6 3 0] point is inside the block.

No comments:

Post a Comment