Language: C++

#include <iostream>
#include <string>
#include <vector>

#include "queen.hpp"

using namespace std;

void Input(Queen* queen) {
	int placementNum;
	cin >> placementNum;
	for (int i = 0; i < placementNum; i++) {
		int row_id;
		int col_id;
		cin >> row_id >> col_id;
//		queen->is_exist_Queen_board[row_id][col_id] = true;
		queen->row[row_id] = col_id;
		queen->col[col_id] = NOT_FREE;
		queen->plus_diagonal_line[row_id+col_id] = NOT_FREE;
		queen->minus_diagonal_line[row_id-col_id + ROW_COLUMN_NUM - 1] = NOT_FREE;
	}
}
void initialize(Queen* queen) {
	for (int i = 0; i < ROW_COLUMN_NUM; i++) {
		queen->row[i] = FREE;
		queen->col[i] = FREE;
	}
	for (int i = 0; i < 2 * ROW_COLUMN_NUM - 1; i++) {
		queen->plus_diagonal_line[i] = FREE;
		queen->minus_diagonal_line[i] = FREE;
	}
	for (int i = 0; i < kRowNum; i++) {
		for (int j = 0; j < kColumnNum; j++) {
			queen->is_exist_Queen_board[i][j] = false;
		}
	}
}

static int cnt_debug = 1;
void PrintForDebug(const Queen& queen){
	cout << cnt_debug++ << "回目" << endl;

	cout << "row : ";
	for (int i = 0; i < ROW_COLUMN_NUM; i++) {
		cout << queen.row[i] << " ";
	}
	cout << endl;
	cout << "col  : ";
	for (int i = 0; i < ROW_COLUMN_NUM; i++) {
		cout << queen.col[i] << " ";
	}
	cout << endl;
	cout << "dpos  : ";
	for (int i = 0; i < 2 * ROW_COLUMN_NUM - 1; i++) {
		cout << queen.plus_diagonal_line[i] << " ";
	}
	cout << endl;
	cout << endl;
	cout << "minus_diagonal_line  : ";
	for (int i = 0; i < 2 * ROW_COLUMN_NUM - 1; i++) {
		cout << queen.minus_diagonal_line[i] << " ";
	}
	cout << endl;


	cout << "+--+--+--+--+--+--+--+--+" << endl;
	for (int y = 0; y < kRowNum; y++){
		for (int x = 0; x < kColumnNum; x++){
			if(queen.row[y] == x){
				printf(" | Q");
			}
			else{
				printf(" |   ");
			}
		}
		printf("|\n");
		cout << "+--+--+--+--+--+--+--+--+" << endl;
	}
}

void printBoard(const Queen& queen) {
//	for (int i = 0; i < kRowNum; i++) {
//		for (int j = 0; j < kColumnNum; j++) {
//			if (queen.is_exist_Queen_board[i][j] && queen.row[i] != j) {
//					return;
//			}
//		}
//	}
	for (int i = 0; i < kRowNum; i++) {
		for (int j = 0; j < kColumnNum; j++) {
			cout << ((queen.row[i] == j) ? "Q" : ".");
		}
		cout << endl;
	}
//	counter++;
}

void recursive(const Queen& input_queen,Queen queen, int row) {
	if (row == 2) { // クイーンの配置に成功
//		PrintForDebug(queen);
		printBoard(queen);
		return;
	}

	for (int j = 0; j < kColumnNum; j++) {
		// (i, j) が他のクイーンに襲撃されている場合は無視
		if (queen.col[j] == NOT_FREE || queen.plus_diagonal_line[row + j] == NOT_FREE || queen.minus_diagonal_line[row - j + ROW_COLUMN_NUM - 1] == NOT_FREE)
			continue;
		// (i, j) にクイーンを配置する
		queen.row[row] = j;
		queen.col[j] = NOT_FREE;
		queen.plus_diagonal_line[row + j] = NOT_FREE;
		queen.minus_diagonal_line[row - j + ROW_COLUMN_NUM - 1] = NOT_FREE;
		// 次の行を試す
		recursive(input_queen,queen, row + 1);
		// (i, j) に配置されているクイーンを取り除く
//		queen.row[i] = queen.col[j] = queen.plus_diagonal_line[i + j] = queen.minus_diagonal_line[i - j + ROW_COLUMN_NUM - 1] = FREE;
		queen.row[row] = FREE;
		queen.col[j] = input_queen.col[j];
		queen.plus_diagonal_line[row + j] = input_queen.plus_diagonal_line[row+j];
		queen.minus_diagonal_line[row - j + ROW_COLUMN_NUM - 1] = input_queen.minus_diagonal_line[row - j + ROW_COLUMN_NUM - 1];

	}
	// クイーンの配置に失敗
}
/*
 * testcase.hpp
 *
 *  Created on: 2020/06/11
 *      Author: 113256
 */

#ifndef TESTCASE_HPP_
#define TESTCASE_HPP_

const int kRowNum = 8;
const int kColumnNum = 8;

#define ROW_COLUMN_NUM 8
#define FREE -1
#define NOT_FREE 1

struct Queen{
	//各行において何列目にQが存在するか
	int row[kRowNum];
	//各列においてQをおけるかどうか
	int col[kColumnNum];
	int plus_diagonal_line[2 * ROW_COLUMN_NUM - 1];
	int minus_diagonal_line[2 * ROW_COLUMN_NUM - 1];

	bool is_exist_Queen_board[kRowNum][kColumnNum];
};

void initialize(Queen* queen);
void Input(Queen* queen);

void recursive(const Queen& input_queen,Queen queen, int i);

#endif /* TESTCASE_HPP_ */
#include "queen.hpp"

int main(){
	Queen input_queen;
    initialize(&input_queen);
    Input(&input_queen);

    recursive(input_queen,input_queen, 0 );

    return 0;
}
/*
 * test.cpp
 *
 *  Created on: 2020/06/10
 *      Author: 113242
 */
#include<iostream>
#include<fstream>
#include<string>

#include "gtest/gtest.h"
#include "../src/puzzle.hpp"
#include "../src/puzzle15.cpp"

using namespace std;

#define TEST_CASE_NUM 28


int main(int argc, char **argv) {
	printf("Running main() from %s\n", __FILE__);
	testing::InitGoogleTest(&argc, argv);
	return RUN_ALL_TESTS();
}

#define main MAIN
#include "../src/main.cpp" // テスト対象のメイン

// テストケースのファイルパス
class Puzzle15Test : public ::testing::TestWithParam<int>{
public:
	const string in_path = "./test_data/";
	const string out_path = "./test_data/";
};

//値をパラメータ化したテスト
TEST_P(Puzzle15Test, CalcCheck) {

	// テストケースのファイル名
	string in_file = "in" + to_string(GetParam()) + ".txt";
	string out_file = "out" + to_string(GetParam()) + ".txt";

	ifstream in_texts(in_path + in_file);
	ASSERT_TRUE(in_texts);
	ifstream out_texts(out_path + out_file);
	ASSERT_TRUE(out_texts);


	string correct_out = string(istreambuf_iterator<char>(out_texts),
				istreambuf_iterator<char>());

	//入力値を設定
	cin.rdbuf(in_texts.rdbuf());
	testing::internal::CaptureStdout();

	MAIN();

	ASSERT_STREQ(correct_out.c_str(),
						testing::internal::GetCapturedStdout().c_str());

}

//テストケースをインスタンス化
INSTANTIATE_TEST_SUITE_P(TEST_INSTANCE, Puzzle15Test,
  ::testing::Range(1, TEST_CASE_NUM + 1, 1));



Compiler output:
a.cc:5:10: fatal error: queen.hpp: No such file or directory
    5 | #include "queen.hpp"
      |          ^~~~~~~~~~~
compilation terminated.