Professional Documents
Culture Documents
#include <iostream>
#include <string>
int x=0,y=0;
if (moves[i]=='U')
y +=(int(moves[i+1])-48);
if (moves[i]=='D')
y -=(int(moves[i+1])-48);
if (moves[i]=='R')
x +=(int(moves[i+1])-48);
if (moves[i]=='L')
x -=(int(moves[i+1])-48);
return distance;
return true;
if (n>=1)
if(sqrt((float)n)==int(sqrt((float)n)))
return true;
return false;
}
int main()
string moves;
int distance;
distance=move(moves);
cout << "The distance the vehicle has moved from the origin to the current point is: "<< distance
<< '\n';
int n=distance;
//squared = isSquared(n);
if (primality(n)) {
cout << "Number " << distance << " is prime number\n";
if (squared(n)) {
cout << "Number " << distance << " is square number\n";
return 0;