Problem p00241 (C++)

Buggy submission (status: Runtime Error):
#ifdef __GNU_C__
#include <bits/stdc++.h>
#else
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <memory.h>
#include <sstream>
#include <string>
#include <vector>
#endif // __GNU_C__

using namespace std;

#define REP(i, max) for (int i = 0, iMax = max; i < iMax; i++)
#define RREP(i, min, max) for (int i = min, iMax = max; i < iMax; i++)
#define EREP(i, min, max) for (int i = min, iMax = max; i <= iMax; i++)
#define REV(i, max) for (int i = max - 1; i >= 0; i--)
#define RREV(i, min, max) for (int i = max, iMin = min; i > iMin; i--)
#define EREV(i, min, max) for (int i = max - 1, iMin = min; i >= iMin; i--)

typedef unsigned long long u64;

struct Quaternion {
  int q[4];

  void Print() { ::scanf("%d %d %d %d\n", q[0], q[1], q[2], q[3]); }
  Quaternion operator*(Quaternion &o) {
    /*		static int	eddingtonEpsilon[][][]	=
                    {
                            {{0, 0, 0}, {0, 0, 1}, {-1, 0, 0} },
                            {{0, 0, -1}, {0, 0, 0}, {1, 0, 0} },
                            {{0, 1, 0}, {-1, 0, 0}, {0, 0, 0} },
                    };
    */
    return Quaternion(
        q[0] * o.q[0] - q[1] * o.q[1] - q[2] * o.q[2] - q[3] * o.q[3],
        q[2] * o.q[3] - q[3] * o.q[2] + q[0] * o.q[1] + q[1] * o.q[0],
        q[3] * o.q[1] - q[1] * o.q[3] + q[0] * o.q[2] + q[2] * o.q[0],
        q[1] * o.q[2] - q[2] * o.q[1] + q[0] * o.q[3] + q[3] * o.q[0]);
  }

  Quaternion() {}
  Quaternion(int ct, int x, int y, int z) {
    q[0] = ct, q[1] = x, q[2] = y, q[3] = z;
  }
};

int main(int args, char *psArgs[]) {
  int numQuaternions;
  vector<Quaternion> quaternions;

  while (::scanf("%d", &numQuaternions), numQuaternions) {
    while (numQuaternions--) {
      Quaternion a, b;

      ::scanf("%d %d %d %d", &a.q[0], &a.q[1], &a.q[2], &a.q[3]);
      ::scanf("%d %d %d %d", &b.q[0], &b.q[1], &b.q[2], &b.q[3]);
      (a * b).Print();
    }
  }
}

Fixed submission:
#ifdef __GNU_C__
#include <bits/stdc++.h>
#else
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <memory.h>
#include <sstream>
#include <string>
#include <vector>
#endif // __GNU_C__

using namespace std;

#define REP(i, max) for (int i = 0, iMax = max; i < iMax; i++)
#define RREP(i, min, max) for (int i = min, iMax = max; i < iMax; i++)
#define EREP(i, min, max) for (int i = min, iMax = max; i <= iMax; i++)
#define REV(i, max) for (int i = max - 1; i >= 0; i--)
#define RREV(i, min, max) for (int i = max, iMin = min; i > iMin; i--)
#define EREV(i, min, max) for (int i = max - 1, iMin = min; i >= iMin; i--)

typedef unsigned long long u64;

struct Quaternion {
  int q[4];

  void Print() { ::printf("%d %d %d %d\n", q[0], q[1], q[2], q[3]); }
  Quaternion operator*(Quaternion &o) {
    /*		static int	eddingtonEpsilon[][][]	=
                    {
                            {{0, 0, 0}, {0, 0, 1}, {-1, 0, 0} },
                            {{0, 0, -1}, {0, 0, 0}, {1, 0, 0} },
                            {{0, 1, 0}, {-1, 0, 0}, {0, 0, 0} },
                    };
    */
    return Quaternion(
        q[0] * o.q[0] - q[1] * o.q[1] - q[2] * o.q[2] - q[3] * o.q[3],
        q[2] * o.q[3] - q[3] * o.q[2] + q[0] * o.q[1] + q[1] * o.q[0],
        q[3] * o.q[1] - q[1] * o.q[3] + q[0] * o.q[2] + q[2] * o.q[0],
        q[1] * o.q[2] - q[2] * o.q[1] + q[0] * o.q[3] + q[3] * o.q[0]);
  }

  Quaternion() {}
  Quaternion(int ct, int x, int y, int z) {
    q[0] = ct, q[1] = x, q[2] = y, q[3] = z;
  }
};

int main(int args, char *psArgs[]) {
  int numQuaternions;
  vector<Quaternion> quaternions;

  while (::scanf("%d", &numQuaternions), numQuaternions) {
    while (numQuaternions--) {
      Quaternion a, b;

      ::scanf("%d %d %d %d", &a.q[0], &a.q[1], &a.q[2], &a.q[3]);
      ::scanf("%d %d %d %d", &b.q[0], &b.q[1], &b.q[2], &b.q[3]);
      (a * b).Print();
    }
  }
}