Quantum Computing Simulation  
010000101110011010100111101101101110100110111111000010101000100110101001101110101101100010100111100000111111010010100001101000101011111111100010101100111111100000101011011110011010101101111111

Simulating Two Quantum Bits

//    q1 q0
// a0  0 0
// a1  0 1
// a2  1 0
// a3  1 1
//
void X( Complex a[], int k) // NOT on qubit k
{
   if( k == 0) { swap( a, 0, 1); swap( a, 2, 3); }

   else        { swap( a, 0, 2); swap( a, 1, 3); }
}
void CX( Complex a[], int c, int k) // controlled-NOT on qubit k controlled by qubit c
{
   if( c == 1) swap( a, 2, 3); else swap( a, 1, 3);
}
void Z( Complex a[], int k) // phase-flip qubit k
{
   if( k == 0) { a[1] = -a[1]; a[3] = -a[3]; }

   else        { a[2] = -a[2]; a[3] = -a[3]; }
}
...
int main( void) { Complex a[4] = { 1, 0, 0, 0 };
...