Implement a C++ program which describes the drawing process of an Ulam spiral. The program should ask the user to enter three variables: startX, startY and step. Then the program should start displaying what actually happens in the drawing process. First of all drawing happens in the following direction order: top, right, down, left. The coordinate system you should use is an rectangle. The upper-left corner of the rectangle has coordinates (0,0). The biggest value for x is 300 and for y is 250. If the next line that should be drawn is leaving the rectangle show a message that this was the last line if the Ulam spiral. There's a simple example.
What have you tried so far? We aren't a homework solution site. We're more than happy to help with problems you are having, but we won't solve them for you.
Have you made an attempt at solving the problem yet? If so, what issues are you facing in your implementation?
//A program which describes the drawing process of an Ulam spiral
#include <iostream>
using namespace std;
int main()
{ const int MAX_X=300;
const int MAX_Y=250;
const int MIN_X=0;
const int MIN_Y=0;
int x, y, k = 0, step;
//The program asks the user to enter three variables: startX, startY and step.
cout << "Enter integer values for the three variables. The maximum for startX is 300 and for startY - 250:"<<endl<<endl<<"startX = ";
cin >> x;
cout <<"startY = ";
cin >> y;
cout <<"step = ";
cin >> step;
if (!cin)
{
cout <<endl<<"No Ulam spiral for you! "<<endl;
return 1;
}
else if (x>MAX_X && y>MAX_Y)
{
cout <<endl<<"No Ulam spiral for you! "<<endl;
return 1;
}
else
{ if (y-step>MIN_Y)
{
while (MIN_X<=x<=MAX_X && MIN_Y<=y<=MAX_Y)
}
else cout <<"No lines to draw!";
}
system ("pause");
return 0;
}
That's what I've written. I don't know if it should be with while and how exactly to continue with the loop.