コード例 #1
0
ファイル: initbbs.c プロジェクト: OmniBus/hkday-pttbbs
int main(int argc, char **argv)
{
    if( argc != 2 || strcmp(argv[1], "-DoIt") != 0 ){
	fprintf(stderr,
		"警告!  initbbs只用在「第一次安裝」的時候.\n"
		"若您的站台已經上線,  initbbs將會破壞掉原有資料!\n\n"
		"將把 BBS 安裝在 " BBSHOME "\n\n"
		"確定要執行, 請使用 initbbs -DoIt\n");
	return 1;
    }

    if(chdir(BBSHOME)) {
	perror(BBSHOME);
	exit(1);
    }
    
    initDir();
    initHome();
    initBoardsDIR();
    initManDIR();
    initPasswds();
    initBoards();
    initMan();
    initSymLink();
    initHistory();
    
    return 0;
}
コード例 #2
0
ファイル: prob3.cpp プロジェクト: Horimotsu/AIhomework
int main() {
	initBoards();
	std::stack<Node> st;
	std::vector<Node> result;
	std::vector<Node> result2;
	int nNode = 0;

	auto start = std::chrono::system_clock::now();
	//Push first Nodes
	for (int i = 0; i < BOARD_SIZE * BOARD_SIZE; i++) {
		for (int j = 0; j < BOARD_SIZE * BOARD_SIZE; j++) {
			if (i == j) continue;
			Node root;
			root.knight = j;
			root.queens.push_back(i);
			st.push(root);
		}
	}

	//Depth first search
	while (!st.empty()) {
		nNode++;
		Node now = st.top(); st.pop();
		int nQueens = now.queens.size();
		if (nQueens == MAX_QUEEN_NUM) {
			if (attackAll(now)) {
				result.push_back(now);
			}
		}
		else {
			int last = now.queens[nQueens - 1];
			for (int i = last + 1; i < BOARD_SIZE * BOARD_SIZE; i++) {
				if (i == now.knight) continue;
				Node next;
				for (int j = 0; j < nQueens; j++) {
					next.queens.push_back(now.queens[j]);
				}
				next.knight = now.knight;
				next.queens.push_back(i);
				st.push(next);
			}
		}
	}

	std::cout << "NODE_NUM" << std::endl;
	std::cout << nNode << std::endl;
	std::cout << "RESULT_NUM" << std::endl;
	std::cout << result.size() << std::endl;
	for (Node node : result) printBoard(node);

	result2 = deleteRotateOrMirrorNodes(result);
	std::cout << "MIRROR NAD ROTATED DELETED" << std::endl;
	std::cout << "RESULT_NUM" << std::endl;
	std::cout << result2.size() << std::endl;
	for (Node node : result2) printBoard(node);
	auto end = std::chrono::system_clock::now();
	std::cout << "Finished in " << std::chrono::duration_cast<std::chrono::milliseconds> (end - start).count() << " msec " << std::endl;
	getchar();
}