Example #1
0
Path& Path::assign(const std::string& sPath, Style style)
{
    switch (style)
    {
    case PATH_UNIX:
        parseUnix(sPath);
        break;
    case PATH_WINDOWS:
        parseWindows(sPath);
        break;
    case PATH_NATIVE:
        assign(sPath);
        break;
    case PATH_GUESS:
        parseGuess(sPath);
        break;
    default:
        throw BadParameterException();
    }
    return *this;
}
Example #2
0
Path& Path::assign(const std::string& path, Style style)
{
	switch (style)
	{
	case PATH_UNIX:
		parseUnix(path);
		break;
	case PATH_WINDOWS:
		parseWindows(path);
		break;
	case PATH_VMS:
		parseVMS(path);
		break;
	case PATH_NATIVE:
		assign(path);
		break;
	case PATH_GUESS:
		parseGuess(path);
		break;
	default:
		break;
	}
	return *this;
}
Example #3
0
int main(int argc, char* argv[]) {
    srand((unsigned)time(NULL));
    int N = 5;
    if (argc > 1) 
        N = atoi(argv[1]);
    
    int i, j; //To be used in future loops

    Complex** c = create2DComplexArray(N);
    
    //Counters for stats:
    int correctFirstTime = 0,
        correctNTime = 0,
        correctWithHints = 0;

    //Main loop1:
    int iteratorCounter1 = 1,
        maxIterations1 = 1000000; //To guarantee no infinite loops
    do {
        int x = rand() % N,
            y = rand() % N;

        Complex* c_Origin = &c[0][0];
        Complex* c_Selected = &c[x][y];

        int hintsUsed = 0;

        //Main loop2:
        int iteratorCounter2 = 1,	
            maxIterations2 = 1000000; //To guarantee no infinite loops
        do {
            printf("M[0][0]=%p. M[i][j]=%p. What's i and j? (or Q or H or HH or HHH): ", c_Origin, c_Selected);

            char* userInput = malloc(36 * sizeof(char));
            fgets(userInput, 36, stdin);
            if (userInput[0] == 'Q' || userInput[0] == 'q') {
                free(userInput);
                goto exit;
            }
            else if (userInput[0] == 'H' || userInput[0] == 'h') {
                int hCount = 0;
                for (i = 0; i < 32; i++) {
                    if (userInput[i] == 'H' || userInput[i] == 'h')
                        hCount++;
                    else break;
                }
                free(userInput);
                hintsUsed++;
                showHints(hCount, c, N);
            }
            else
            {
                int* parsedResult = parseGuess(userInput);
                int _x = parsedResult[0];
                int _y = parsedResult[1];
                free(parsedResult);
                free(userInput);
                if (_x == -1 || y == -1)
                    continue;
                if (x == _x && y == _y) {
                    printf("RIGHT\n");
                    if (hintsUsed > 0)
                        correctWithHints++;
                    else if (iteratorCounter2 > 1)
                        correctNTime++;
                    else
                        correctFirstTime++;
                    break;
                }
                else
                {
                    printf("WRONG\n");
                    continue;
                }
            }
        } while (iteratorCounter2++ < maxIterations2);
    } while (iteratorCounter1++ < maxIterations1);

exit: 
    free2DArray(c, N);
    printStats(--iteratorCounter1, correctFirstTime, correctNTime, correctWithHints);
    return 0;
}