Exemplo n.º 1
0
int main() {
	int a1, b1, a2, b2; char c1, c2;
	while (cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2) {
		double x1 = trans_x(a1, b1, c1);
		double y1 = trans_y(a2, b2, c2);
		cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;
		double x2 = trans_x(a1, b1, c1);
		double y2 = trans_y(a2, b2, c2);

		printf("%.3f\n", 6370 * acos(cos(x1) * cos(x2) * cos(y2 - y1) + sin(x1) * sin(x2)));
	}
	return 0;
}
Exemplo n.º 2
0
Arquivo: board.c Projeto: photz/conway
cell_t get_cell(const board_t* board, pos_t pos)
{
  assert(NULL != board);

  assert(is_valid_board(board));

  if (is_set(board->b[W][pos.y], trans_x(pos.x)))
    {
      return WHITE;
    }
  else if (is_set(board->b[B][pos.y], trans_x(pos.x)))
    {
      return BLACK;
    }

  return EMPTY;
}
Exemplo n.º 3
0
Arquivo: board.c Projeto: photz/conway
void set_cell(board_t* board, player_t player, pos_t pos)
{
  assert(NULL != board);

  assert(is_valid_pos(pos));

  assert(is_valid_board(board));

  // make sure the given cell is empty
  assert(EMPTY == get_cell(board, pos));

  board->b[player][pos.y] = set(board->b[player][pos.y], trans_x(pos.x));
}
Exemplo n.º 4
0
Arquivo: board.c Projeto: photz/conway
void set_cell_state(board_t* board, pos_t pos, cell_t new_state)
{
  assert(NULL != board);
  
  assert(is_valid_board(board));

  assert(is_valid_pos(pos));


  /* // this assertion is tentative, it may prove too strict */
  /* // it relies on the caller checking the state of this cell */
  /* // before trying to change it */
  /* const cell_t old_state = get_cell(board, pos); */
  /* assert(new_state != old_state); */

  
  row* white_col = &board->b[W][pos.y];
  row* black_col = &board->b[B][pos.y];


  switch (new_state)
    {
    case WHITE:
      *black_col = unset(*black_col, trans_x(pos.x));
      *white_col = set(*white_col, trans_x(pos.x));
      break;

    case BLACK:
      *white_col = unset(*white_col, trans_x(pos.x));
      *black_col = set(*black_col, trans_x(pos.x));
      break;

    case EMPTY:
      // deactivate the bit representing the cell at _pos_
      // we apply the macro to both columns because we don't
      // know to which player it belongs

      *white_col = unset(*white_col, trans_x(pos.x));
      *black_col = unset(*black_col, trans_x(pos.x));
    }


  // make sure we didn't corrupt the board in the process of
  // updating the cell
  assert(is_valid_board(board));
}