int shunt(PStack input) {
Val datum;
char *test;
int count=0;
int i;
do {
datum = pull(input);
TokeBase++;
if(datum.s[0] == ';') break;
if(datum.s[0] == ')') count--;
if(datum.s[0] == '(') count++;
if(Oper.fill)
while((prec(datum.s) < prec(top(&Oper).s) ) )
lift(&Output,pop(&Oper));
push(&Oper,datum);
} while(count);
while(Oper.fill) {
datum= pop(&Oper);
if((datum.s[0] != '(') && (datum.s[0] != ')'))
lift(&Output,datum);
}
}
The Tower of Hanoi (also called the Tower of Brahma or Lucas' Tower[1] and sometimes pluralized) is a mathematical game or puzzle. It consists of three rods and a number of disks of different sizes, which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.
No comments:
Post a Comment