0

Finding Robotic Path and Distance

Posted March 24th, 2010 in Programming Corner and tagged by Paran

#include<iostream.h>

#include<conio.h>

#include<math.h>

void main()

{ clrscr();

int x,x1,y,y1,i=0;

x=x1=35; y=y1=12;

cout<<”\t Starting point ( 35,12 ).\n\t Starting point is notified by * “;

char *comm;

cout<<”\n\tGive your command:”;

cin>>comm;

gotoxy(x,y);

cout<<”*”;

while(comm[i]!=’ ‘)

{ if(comm[i]==’n’)

{ y–;

gotoxy(x,y);

cout<<”n”;

}

if(comm[i]==’s’)

{ x++;

gotoxy(x,y);

cout<<”s”;

}

if(comm[i]==’e’)

{ y++;

gotoxy(x,y);

cout<<”e”;

}

if(comm[i]==’w’)

{ x–;

gotoxy(x,y);

cout<<”w”;

}

i++;

}

cout<<”\n\tEnd point ( “<<x<<” , “<<y<<” )”;

float dist=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));

gotoxy(9,16);

cout<<”Total distance : “<<dist;

getch();

}

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Facebook
  • Twitter
  • Google Bookmarks
  • Print
  • Live
  • Digg
  • Sphinn
  • Mixx
  • Add to favorites

Leave a Reply





  • Page 1 of 1
  • « Previous
  • 1
  • Next »
Website Visitor Movie