Пример #1
0
int main(){
    int ch='X';
//Creates the 3 stacks; initially empty (head points to tail)
    headA=initLLNode(100);
	tailA=initLLNode(100);
	headA->next=tailA;
	headB=initLLNode(101);
	tailB=initLLNode(101);
	headB->next=tailB;
	headC=initLLNode(102);
	tailC=initLLNode(102);
	headC->next=tailC;

//repeat the prompt until the user enters the ESC key.
//(esc corresponds to ASCII value 27, so we repeat while ch is not equal to 27)
	while(ch!=27){
		if(ch==49)play(); //if 1 entered, start play mode
		if(ch==50)Demo(); //if 2 entered, demo mode
		if(ch==51)hof();  //if 3 entered, go to hall of face
		system("cls");    //this clears the screen
		printf("Tower of Hanoi\n"
			"==============================\n"
			"Press 1 to go to Game Mode.\n"
			"Press 2 to go to Demo Mode.\n"
			"Press 3 to go to Hall of Fame.\n"
			"Press ESC to Exit.\n");
        emptyStacks();    //initalizes the stacks (explained at function definition)
		ch = getch();     //gets user input
	}
	return 0;
}
Пример #2
0
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
        switch (Msg) {
	case WM_USER:
		switch (lParam) {
		case WM_LBUTTONDBLCLK:
			ShowWindow(hWndDlg, SW_SHOW);
			return TRUE;
		}
		break;
		
	case WM_TERM:
		do_stop(hWndDlg);
		break;

	case WM_INITDIALOG:
		_hwnd = hWndDlg;
		do_init();
		do_stop(_hwnd);

		start_stop(hWndDlg); /* didn't we say on by default? ;D */
		break;

	case WM_SYSCOMMAND:
		if ((wParam & 0xfff0) == SC_MINIMIZE) {
			minimize(hWndDlg);
			return TRUE;
		}
		break;

        case WM_CLOSE:
		minimize(hWndDlg);
                return TRUE;

        case WM_COMMAND:
                switch(wParam) {
		case IDOK:
			start_stop(hWndDlg);
			return TRUE;
		case IDCANCEL:
			netstat();
			return TRUE;

		case IDC_BUTTON1:
			EndDialog(hWndDlg, 0);
			return TRUE;

		case IDC_BUTTON2:
			hof();
			return TRUE;
		}
		break;
	}

	return FALSE;
}
Пример #3
0
int main(int argc, char **argv) {
    if (argc < 5)   {
        cout<<"Usage: "<<argv[0]<<" projMatList rMeanList codeBookList outputBase [windowSize] [stepSize] [intSize]"<<endl;
        return 0;
    }
    string projMatList(argv[1]);
    string rMeanList(argv[2]);
    string codeBookList(argv[3]);
    string outputBase(argv[4]);
    int windowSize = 100;
    int stepSize = 100;
    int intSize = 100;
    if (argc > 5)
        windowSize = atoi(argv[5]);
    if (argc > 6)
        stepSize = atoi(argv[6]);
    if (argc > 7)
        intSize = atoi(argv[7]);
    if (windowSize % intSize != 0 || stepSize % intSize != 0)   {
        cout<<"Integral size must be the gcd of window size and step size."<<endl;
        return 0;
    }
    string types[5] = {"traj", "hog", "hof", "mbhx", "mbhy"};
    vector<TeVector*> tevs(5, NULL);

    ifstream fin1, fin2, fin3;
    fin1.open(projMatList.c_str());
    if (!fin1.is_open())    {
        cout<<"Cannot open "<<projMatList<<endl;
        return 0;
    }
    fin2.open(codeBookList.c_str());
    if (!fin2.is_open())    {
        cout<<"Cannot open "<<codeBookList<<endl;
        return 0;
    }
    fin3.open(rMeanList.c_str());
    if (!fin3.is_open())    {
        cout<<"Cannot open "<<rMeanList<<endl;
        return 0;
    }
    string projMatFile, codeBookFile, rMeanFile;
    //for (int i = 0; i < fvs.size(); i++)    {
    for (int i = 1; i < tevs.size(); i++)    {
        getline(fin1, projMatFile);
        getline(fin2, codeBookFile);
        getline(fin3, rMeanFile);
        tevs[i] = new TeVector(codeBookFile, rMeanFile, projMatFile);
        tevs[i]->initTeV(intSize);  // 1 layer of spatial pyramids
    }
    fin1.close();
    fin2.close();
    fin3.close();

    string line;
    cout<<"Start loading points..."<<endl;
    while (getline(cin, line))  {
        DTFeature feat(line);
        //TODO: Store feature of DT with vector<double>
        //vector<double> traj(feat.traj, feat.traj+TRAJ_DIM);
        vector<double> hog(feat.hog, feat.hog+HOG_DIM);
        vector<double> hof(feat.hof, feat.hof+HOF_DIM);
        vector<double> mbhx(feat.mbhx, feat.mbhx+MBHX_DIM);
        vector<double> mbhy(feat.mbhy, feat.mbhy+MBHY_DIM);
        //tevs[0]->addPoint(traj, feat.frameNum);
        tevs[1]->addPoint(hog, feat.frameNum);
        tevs[2]->addPoint(hof, feat.frameNum);
        tevs[3]->addPoint(mbhx, feat.frameNum);
        tevs[4]->addPoint(mbhy, feat.frameNum);
    }

    cout<<"Points load complete."<<endl;
    //for (int i = 0; i < tevs.size(); i++)    {
    for (int i = 1; i < tevs.size(); i++)    {
        ofstream fout;
        string outName = outputBase + "." + types[i] + ".tev.txt";
        fout.open(outName.c_str());
        vector<double> tev = tevs[i]->getTeV();
        fout<<tev[0];
        for (int j = 1; j < tev.size(); j++)
            fout<<" "<<tev[j];
        fout<<endl;
        fout.close();
        outName = outputBase + "." + types[i] + ".tev.seq";
        fout.open(outName.c_str());
        vector<vector<double> > localTeVs = tevs[i]->getTeV(stepSize, windowSize);
        for (int j = 0; j < localTeVs.size(); j++)   {
            fout<<localTeVs[j][0];
            for (int k = 1; k < localTeVs[j].size(); k++)
                fout<<" "<<localTeVs[j][k];
            fout<<endl;
        }
        fout.close();
        tevs[i]->clearTeV();
    }

    for (int i = 1; i < tevs.size(); i++)
    //for (int i = 0; i < fvs.size(); i++)
        delete tevs[i];
    return 0;
}