Language: Java

#include <iostream>
#include <string>
using namespace std;
 
class Dice {
  private:
    int *numbers;
  public:
    Dice(int *numbers) {
      this->numbers = numbers;
    }
 
    int getCurrentNumber() {
      return this->numbers[0];
    }
 
    void turn(char direction) {
      switch (direction) {
        case 'N':
          this->turnNorth();
          break;
        case 'S':
          this->turnSouth();
          break;
        case 'E':
          this->turnEast();
          break;
        case 'W':
          this->turnWest();
          break;
      }
    }
 
    void turnNorth() {
      swap(this->numbers[0], this->numbers[1]);
      swap(this->numbers[1], this->numbers[5]);
      swap(this->numbers[5], this->numbers[4]);
    }
 
    void turnSouth() {
      swap(this->numbers[0], this->numbers[4]);
      swap(this->numbers[4], this->numbers[5]);
      swap(this->numbers[5], this->numbers[1]);
    }
 
    void turnEast() {
      swap(this->numbers[0], this->numbers[3]);
      swap(this->numbers[3], this->numbers[5]);
      swap(this->numbers[5], this->numbers[2]);
    }
 
    void turnWest() {
      swap(this->numbers[0], this->numbers[2]);
      swap(this->numbers[2], this->numbers[5]);
      swap(this->numbers[5], this->numbers[3]);
    }
 
    int getRightNumberFrom(int top, int front) {
      int rightIndexes[6][6] = {
        { -1, 2, 4, 1, 3, -1 },
        { 3, -1, 0, 5, -1, 2 },
        { 1, 5, -1, -1, 0, 4 },
        { 4, 0, -1, -1, 5, 1 },
        { 2, -1, 5, 0, -1, 3 },
        { -1, 3, 1, 4, 2, -1 }
      };
      int topIndex, frontIndex;
      for(int i = 0; i < 6; i++) {
        if (this->numbers[i] == top) topIndex = i;
        if (this->numbers[i] == front) frontIndex = i;
      }
      return this->numbers[rightIndexes[topIndex][frontIndex]];
    }
};
 
int main() {
  int numbers[6], n, top, front;
  int ans[24];
 
  for (int i = 0; i < 6; i++) {
    cin >> numbers[i];
  }
  cin >> n;
  Dice dice(numbers);
  for (int i = 0; i < n; i++) {
    cin >> top >> front;
    ans[i] = dice.getRightNumberFrom(top, front);
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
 
  return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <string>
^
Main.java:6: error: illegal start of type
  private:
         ^
Main.java:7: error: <identifier> expected
    int *numbers;
       ^
Main.java:7: error: <identifier> expected
    int *numbers;
                ^
Main.java:8: error: illegal start of type
  public:
        ^
Main.java:9: error: <identifier> expected
    Dice(int *numbers) {
            ^
Main.java:10: error: not a statement
      this->numbers = numbers;
      ^
Main.java:10: error: ';' expected
      this->numbers = numbers;
          ^
Main.java:14: error: ';' expected
      return this->numbers[0];
                 ^
Main.java:14: error: not a statement
      return this->numbers[0];
                          ^
Main.java:20: error: not a statement
          this->turnNorth();
          ^
Main.java:20: error: ';' expected
          this->turnNorth();
              ^
Main.java:23: error: not a statement
          this->turnSouth();
          ^
Main.java:23: error: ';' expected
          this->turnSouth();
              ^
Main.java:26: error: not a statement
          this->turnEast();
          ^
Main.java:26: error: ';' expected
          this->turnEast();
              ^
Main.java:29: error: not a statement
          this->turnWest();
          ^
Main.java:29: error: ';' expected
          this->turnWest();
              ^
Main.java:35: error: ')' or ',' expected
      swap(this->numbers[0], this->numbers[1]);
               ^
Main.java:35: error: not a statement
      swap(this->numbers[0], this->numbers[1]);
                        ^
Main.java:35: error: ';' expected
      swap(this->numbers[0], this->numbers[1]);
                           ^
Main.java:35: error: not a statement
      swap(this->numbers[0], this->numbers[1]);
                             ^
Main.java:35: error: ';' expected
      swap(this->numbers[0], this->numbers[1]);
                                 ^
Main.java:35: error: not a statement
      swap(this->numbers[0], this->numbers[1]);
                                          ^
Main.java:35: error: ';' expected
      swap(this->numbers[0], this->numbers[1]);
                                             ^
Main.java:36: error: ')' or ',' expected
      swap(this->numbers[1], this->numbers[5]);
               ^
Main.java:36: error: not a statement
      swap(this->numbers[1], this->numbers[5]);
                        ^
Main.java:36: error: ';' expected
      swap(this->numbers[1], this->numbers[5]);
                           ^
Main.java:36: error: not a statement
      swap(this->numbers[1], this->numbers[5]);
                             ^
Main.java:36: error: ';' expected
      swap(this->numbers[1], this->numbers[5]);
                                 ^
Main.java:36: error: not a statement
      swap(this->numbers[1], this->numbers[5]);
                                          ^
Main.java:36: error: ';' expected
      swap(this->numbers[1], this->numbers[5]);
                                             ^
Main.java:37: error: ')' or ',' expected
      swap(this->numbers[5], this->numbers[4]);
               ^
Main.java:37: error: not a statement
      swap(this->numbers[5], this->numbers[4]);
                        ^
Main.java:37: error: ';' expected
      swap(this->numbers[5], this->numbers[4]);
                           ^
Main.java:37: error: not a statement
      swap(this->numbers[5], this->numbers[4]);
                             ^
Main.java:37: error: ';' expected
      swap(this->numbers[5], this->numbers[4]);
                                 ^
Main.java:37: error: not a statement
      swap(this->numbers[5], this->numbers[4]);
                                          ^
Main.java:37: error: ';' expected
      swap(this->numbers[5], this->numbers[4]);
                                             ^
Main.java:41: error: ')' or ',' expected
      swap(this->numbers[0], this->numbers[4]);
               ^
Main.java:41: error: not a statement
      swap(this->numbers[0], this->numbers[4]);
                        ^
Main.java:41: error: ';' expected
      swap(this->numbers[0], this->numbers[4]);
                           ^
Main.java:41: error: not a statement
      swap(this->numbers[0], this->numbers[4]);
                             ^
Main.java:41: error: ';' expected
      swap(this->numbers[0], this->numbers[4]);
                                 ^
Main.java:41: error: not a statement
      swap(this->numbers[0], this->numbers[4]);
                                          ^
Main.java:41: error: ';' expected
      swap(this->numbers[0], this->numbers[4]);
                                             ^
Main.java:42: error: ')' or ',' expected
      swap(this->numbers[4], this->numbers[5]);
               ^
Main.java:42: error: not a statement
      swap(this->numbers[4], this->numbers[5]);
                        ^
Main.java:42: error: ';' expected
      swap(this->numbers[4], this->numbers[5]);
                           ^
Main.java:42: error: not a statement
      swap(this->numbers[4], this->numbers[5]);
                             ^
Main.java:42: error: ';' expected
      swap(this->numbers[4], this->numbers[5]);
                                 ^
Main.java:42: error: not a statement
      swap(this->numbers[4], this->numbers[5]);
                                          ^
Main.java:42: error: ';' expected
      swap(this->numbers[4], this->numbers[5]);
                                             ^
Main.java:43: error: ')' or ',' expected
      swap(this->numbers[5], this->numbers[1]);
               ^
Main.java:43: error: not a statement
      swap(this->numbers[5], this->numbers[1]);
                        ^
Main.java:43: error: ';' expected
      swap(this->numbers[5], this->numbers[1]);
                           ^
Main.java:43: error: not a statement
      swap(this->numbers[5], this->numbers[1]);
                             ^
Main.java:43: error: ';' expected
      swap(this->numbers[5], this->numbers[1]);
                                 ^
Main.java:43: error: not a statement
      swap(this->numbers[5], this->numbers[1]);
                                          ^
Main.java:43: error: ';' expected
      swap(this->numbers[5], this->numbers[1]);
                                             ^
Main.java:47: error: ')' or ',' expected
      swap(this->numbers[0], this->numbers[3]);
               ^
Main.java:47: error: not a statement
      swap(this->numbers[0], this->numbers[3]);
                        ^
Main.java:47: error: ';' expected
      swap(this->numbers[0], this->numbers[3]);
                           ^
Main.java:47: error: not a statement
      swap(this->numbers[0], this->numbers[3]);
                             ^
Main.java:47: error: ';' expected
      swap(this->numbers[0], this->numbers[3]);
                                 ^
Main.java:47: error: not a statement
      swap(this->numbers[0], this->numbers[3]);
                                          ^
Main.java:47: error: ';' expected
      swap(this->numbers[0], this->numbers[3]);
                                             ^
Main.java:48: error: ')' or ',' expected
      swap(this->numbers[3], this->numbers[5]);
               ^
Main.java:48: error: not a statement
      swap(this->numbers[3], this->numbers[5]);
                        ^
Main.java:48: error: ';' expected
      swap(this->numbers[3], this->numbers[5]);
                           ^
Main.java:48: error: not a statement
      swap(this->numbers[3], this->numbers[5]);
                             ^
Main.java:48: error: ';' expected
      swap(this->numbers[3], this->numbers[5]);
                                 ^
Main.java:48: error: not a statement
      swap(this->numbers[3], this->numbers[5]);
                                          ^
Main.java:48: error: ';' expected
      swap(this->numbers[3], this->numbers[5]);
                                             ^
Main.java:49: error: ')' or ',' expected
      swap(this->numbers[5], this->numbers[2]);
               ^
Main.java:49: error: not a statement
      swap(this->numbers[5], this->numbers[2]);
                        ^
Main.java:49: error: ';' expected
      swap(this->numbers[5], this->numbers[2]);
                           ^
Main.java:49: error: not a statement
      swap(this->numbers[5], this->numbers[2]);
                             ^
Main.java:49: error: ';' expected
      swap(this->numbers[5], this->numbers[2]);
                                 ^
Main.java:49: error: not a statement
      swap(this->numbers[5], this->numbers[2]);
                                          ^
Main.java:49: error: ';' expected
      swap(this->numbers[5], this->numbers[2]);
                                             ^
Main.java:53: error: ')' or ',' expected
      swap(this->numbers[0], this->numbers[2]);
               ^
Main.java:53: error: not a statement
      swap(this->numbers[0], this->numbers[2]);
                        ^
Main.java:53: error: ';' expected
      swap(this->numbers[0], this->numbers[2]);
                           ^
Main.java:53: error: not a statement
      swap(this->numbers[0], this->numbers[2]);
                             ^
Main.java:53: error: ';' expected
      swap(this->numbers[0], this->numbers[2]);
                                 ^
Main.java:53: error: not a statement
      swap(this->numbers[0], this->numbers[2]);
                                          ^
Main.java:53: error: ';' expected
      swap(this->numbers[0], this->numbers[2]);
                                             ^
Main.java:54: error: ')' or ',' expected
      swap(this->numbers[2], this->numbers[5]);
               ^
Main.java:54: error: not a statement
      swap(this->numbers[2], this->numbers[5]);
                        ^
Main.java:54: error: ';' expected
      swap(this->numbers[2], this->numbers[5]);
                           ^
Main.java:54: error: not a statement
      swap(this->numbers[2], this->numbers[5]);
                             ^
Main.java:54: error: ';' expected
      swap(this->numbers[2], this->numbers[5]);
                                 ^
Main.java:54: error: not a statement
      swap(thi