I'm trying to solve a typical stacks problem, but I'm a bit stuck, I'm afraid.
The task sounds like this: There is a stack of plates in a certain order, A, and a stack called B which contains the order in which stack A has to be moved. You have to output the sequence of moves "in_number_plate" and "out_number_plate" so you'll get the plates from the stack B. If it's not possible, output a message when you get in that position.
Basically, I know what stacks are and how to add/remove items from it, and I have a brief idea of how the program should look like, but it doesn't work. (great, ain't it ?).
Anyway, this is what I did so far:
[thanks in advance]
#include <iostream>
#include <string.h>
using namespace std;
int main ()
{
char A[5], B[5], C[5];
int T, i, j;
cout<<"Plates from A: ";
cin.get (A, 4);
cin.get ();
cout<<"Plates from B: ";
cin.get (B, 4);
T=3;
for (i=0; i<=4; i++)
for (j=0; j<=4; j++)
{
if (A[i]<B[j])
{
cout<<"in_ "<<A[i]<<endl;
T++;
C[T]=B[j];
}
if (A[i]>B[j])
{
cout<<"out_ "<<A[i]<<endl;
T--;
}
if (A[i+1]>A[i])
cout<<"Impossible for: "<<A[i]<<endl;
}
}