Help me with my task

Task 1 Ulam spiral

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.

Input: startX = 150, startY = 150, step = 50

Output:

Line number 1 (up): (150, 150) ---> (150, 100)

Line number 2 (right): (150, 100) ---> (200, 100)

Line number 3 (down): (200, 100) ---> (200, 200)

Line number 4 (left): (200, 200) ---> (100, 200)

Line number 5 (up): (100, 200) ---> (100, 50)

Line number 6 (right): (100, 50) --> (250, 50)

Line number 7 (down): (250, 50) --> (250, 250)

Line number 8 (left): (250, 250) --> (50, 250)

Line number 9 (up): (50, 250) --> (50, 0)

Line number 10 (right): (50, 0) --> (300, 0)

LAST LINE DRAWN!!!!



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.
Topic archived. No new replies allowed.