예제 #1
0
파일: mancala.c 프로젝트: wfei/hw
// Find the best choice in the searching tree.
Node* findBest(Node *root, int depth) {
    int i;
    Node* best = NULL;
    Node* cur = NULL;
    switch (depth) {
    case 1:
	best = findGreatest(root);
	break;
    case 2:
	cur = findGreatest(root);
	best = findSmallest(cur);
	break;
    case 3:
	cur = findGreatest(root);
	best = findSmallest(cur);
	best = findGreatest(best);
	break;
    }
    return best;
}
예제 #2
0
int main(int argc, char *argv[])
{
	struct CNumGrid theGrid;
	struct CProdHelper grProdLoc;
	int count, i;
	if (initCNumGrid(&theGrid, "grid.dat")) {
		printf("File not readable. Please try again.\n");
		return 0;
	}
	
	printGrid(&theGrid);
	
	grProdLoc = findGreatest(&theGrid);
	
	printf("Location of the greatest product = (%d, %d)\n", grProdLoc.x, grProdLoc.y);
	printf("Greatest product = %d\n", grProdLoc.prod);
	
	system("PAUSE");	
	return 0;
}