marble automata c++
#include<iostream>
#define MAX 3
using namespace std;
int main()
{
int myArray[MAX];
int value=0;
int i=0;
cout<<"Marble App"<<endl;
cout<<"For Input A(0) and B(1): for exit(2)"<<endl;
cout<<"enter values: ";
while(i<=2)
{
cin>>value;
if(value>1)
break;
else
{
myArray[i]=value;
i++;
}
}
int k=0;
if(i==2)
{
if(myArray[k]==0 && myArray[k+1]==0)
cout<<"output: C"<<endl;
else if(myArray[k]==1 && myArray[k+1]==1)
cout<<"output: D"<<endl;
else
cout<<"output: empty"<<endl;
}
else if(i==3)
{
if(myArray[k]==0 && myArray[k+1]==1 && myArray[k+2]==0 )
cout<<"output: C"<<endl;
else if(myArray[k]==1 && myArray[k+1]==0 && myArray[k+1]==0)
cout<<"output: C"<<endl;
else if(myArray[k]==0 && myArray[k+1]==1 && myArray[k+1]==1)
cout<<"output: D"<<endl;
else if(myArray[k]==1 && myArray[k+1]==0 && myArray[k+1]==1)
cout<<"output: D"<<endl;
else
cout<<"output: empty"<<endl;
}
return 0;
}