#include <iostream>
#include <fstream>

using namespace std;

int main (){
  ofstream output("test.bin", ios::out | ios::binary );
  int count = 400;
  short moves[1000];
  float pis[1000 * 362]; 
  for (int i = 0; i < count; ++i){
    moves[i] = i;
    for (int j = 0; j < 362; ++j){
      pis[i * 362 + j] = float(i + j * 0.001);
    }
  }
  cout << "sizeof(count): " << sizeof(count) << endl;
  cout << "sizeof(moves): " << sizeof(moves) << endl;
  cout << "sizeof(pis): " << sizeof(pis) << endl;
  output.write((char *)&count, sizeof(count));
  output.write((char *)moves, sizeof(short) * count);
  output.write((char *)pis, sizeof(float) * 362 * count);
  output.close();

  int count_in = 400;
  short moves_in[1000];
  float pis_in[1000 * 362]; 
  ifstream input("test.bin", ios::in | ios::binary );
  input.read((char*)&count_in, sizeof(count_in));
  input.read((char*)moves_in, sizeof(short) * count_in);
  input.read((char*)pis_in, sizeof(float) * 362 * count_in);
  input.close();
  cout << count_in << endl;
  for (int i = 0; i < count_in; ++i){
    cout << moves_in[i];
    if (i == count_in - 1) cout << endl;
    else cout << ", ";
  }
  for (int i = 0; i < count_in * 362; ++i){
    cout << pis_in[i];
    if ((i + 1) % 362 == 0){
      cout << endl;
    }else{
      cout << ", ";
    }
  }
  return 0;
}
