#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
void main(){
clrscr();
int xb[13]={80,90,99,108,116,125,133,141,151,160,169,179,180} ;
int yb[13]={0,-2,-5,-9,-15,-18,-23,-29,-28,-25,-21,-20,-17} ;
float xf[13], yf[13], vf= 20.0, sin, cos, time, distance, dist_range=10 ;
xf[0]= 0.0;Â yf[0]= 50.0 ;
for( int i=0; i<13; i++){
distance = sqrt( ( yb[i]-yf[i] ) * ( yb[i]-yf[i] ) + ( xb[i]-xf[i] ) * ( xb[i]-xf[i] ) ) ;
gotoxy( xf[i],yf[i]);
cout<<”b”<<i;
gotoxy( xb[i],yb[i]);
cout<<”f”<<i;
if( distance <= dist_range ){
cout<<”\n\tdistance : “<<distance ;
getch() ;
exit(0) ;
}
else if{
if( time > 12 ){
cout<<”\n\tTarget escepted.” ;
getch() ;
exit(0) ;
}
else{
sin = ( yb[i] – yf[i] )/ distance ;
cos = ( xb[i] – xf[i] )/ distance ;
xf[i+1] = xf[i] + vf * cos ;
yf[i+1] = yf[i] + vf * sin ;
}
}
}
getch();
}
Please share your better concept about this program.
