help me to figure out this example

so i copyed from a book Anmated tower of hanoi code. si i expefcted to see something when i run it. But when i run it i see 4-5 empty lines ans press any key to continue.
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
using namespace std;
#define MAX_LEVELS 10

class mystack{
public:
	int rings[MAX_LEVELS];
	int tos;
	void populate(int size);
	void clear(int size);
	void push(int n);
	int pop(void);
}stacks[3];

void mystack::populate(int size){
	for (int i= 0;i < size; i++)
		rings[i] = 0;
		tos = -1;
}

void mystack::clear(int size){
	for (int i= 0;i < size; i++)
		rings[i] = 0;
		tos = size -1;
}

void mystack::push(int n) {
	rings[tos--] = n;
}

int mystack::pop(void) {
	int n= rings[++tos];
	rings[tos] = 0;
	return n;
}

void move_stacks(int src, int dest, int other, int n);
void move_a_ring(int source, int dest);
void print_stacks(void);
void pr_chars(int ch, int n);
int stack_size = 7;

int main(){
	stacks[0].populate(stack_size);
	stacks[1].clear(stack_size);
	stacks[2].clear(stack_size);
	print_stacks();
	move_stacks(stack_size, 0, 2, 1);
	return 0;
}

void move_stacks(int src, int dest, int other, int n){
	if (n==1)
		move_a_ring(src, dest);
	else{
		move_stacks(n-1, src, other, dest);
		move_a_ring(src, dest);
		move_stacks(n-1, other, dest, src);
	}
}

void move_a_ring(int source, int dest){
	int n = stacks[source].pop();
	stacks[dest].push(n);
	print_stacks();
}

void print_stacks(void){
	int n =0;
	for(int i=0; i < stack_size; i++) {
		for(int j = 0; j <3; j++){
			n= stacks[j].rings[i];
			pr_chars(' ',12-n);
			pr_chars('*', 2* n);
			pr_chars(' ', 12-n);
		}
		cout << endl;
	}
	system("PAUSE");
}

void pr_chars(int ch, int n) {
	for (int i = 0; i< n; i++)
		cout << (char) ch;
}


Is this example broken or is it supposed to do so??
just tell me why doesent this code show me any picture. im getting 4-5 empty lines and then a line saying Press any key to continue. This is not a homework.
void move_stacks(int src, int dest, int other, int n); Move 'n' disk from the rod 'src' to the rod 'dest'. You may use the rod 'other'.
However when you call at the function
1
2
move_stacks(stack_size, 0, 2, 1);
move_stacks(n-1, src, other, dest);
you don't respect the order.

As why it doesn't show anything, it is just printing spaces.
1
2
3
4
5
6
7
8
9
10
11
12
void mystack::populate(int size){
	for (int i= 0;i < size; i++)
		rings[i] = 0;
	tos = -1;
}
//...
		for(int j = 0; j <3; j++){
			n= stacks[j].rings[i]; //n=0
			pr_chars(' ',12-n);
			pr_chars('*', 2*n);
			pr_chars(' ', 12-n);
		}
1
2
3
4
5
6
7
8
9
for(int i=0; i < stack_size; i++) {
		for(int j = 0; j <3; j++){
			n= stacks[j].rings[i];
			pr_chars(' ',12-n);
			pr_chars('*', 2* n);
			pr_chars(' ', 12-n);
		}
		cout << endl;
	}


it should give values to j and i. and the order thid there i just need to reorganize the tihn i ha ve written?
so how can i make it to print something.
1
2
3
4
5
void mystack::populate(int size){
	for (int i= 0;i < size; i++)
		rings[i] = i+1;
	tos = -1;
}
And fix the move_stacks() calls
ok ok now i can see the tower, but since this is animated tower of hanoi shouldt i see the rings meing moed after each turn insstead of the same tower over and over again and again.
Topic archived. No new replies allowed.