How Can i move this figure

*
**
***
****
I want to make this figure to be printed then disappear then printed again as if its moving horizontally once & vertically once & along the diagonal once
by using c++
Last edited on
So you want to print it like this
*
then
**
then
***
then
****

clear screen
repeat

right?
No I want it like this
*
**
***
****
Clear screen
*
**
***
****
Well, I can show you how to do that easily, but its not going to work like you want it too, unless you want the code to be extremely inefficient.
I did it but there is some problems that i can't fix .. could you tell me how to make it work ?
@merna

Here's one way. It's a little messy, and uses a system call, not really recommended, but it was something quick to throw together.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "iostream"
#include <string>
#include <Windows.h>

using namespace std;

int main()
{
	string down = "\n";
	string across = " ";
	cout << "*"<<endl;
	cout << "**" << endl;
	cout << "***";// Only 3 lines, but you get the idea
	for (int x = 0; x < 21; x++)
	{
		Sleep(700);
		system("cls");//Using System calls not good idea
		cout << down<<across<<"*" << endl;
		cout << across << "**" << endl;
		cout << across << "***";
		
		across += " ";
		down += "\n";
	}
    return 0;
}
Thank you
Topic archived. No new replies allowed.