Пример #1
0
bool DC_DateTimeConv::StringToDate(const char* tempStr)
{
    SetParseChars("/-");
    CopyString(parsedStr, tempStr, maxStrLen);
    PrepareParseString(parsedStr, parseChars);

    month = GetNextInt();
    day = GetNextInt();
    year = GetNextInt();

    // check for y m d conversion
    if (month > 12)
    {
        int ty = month;
        int tm = day;
        day = year;
        month = tm;
        year = ty;
    }

    // kluge assuming 2 character tim3e
    if ((year >= 0) && (year < 100))
        if (year > 50)
            year += 1900;
        else
            year += 2000;

    return TimeOK();
}
Пример #2
0
bool DC_DateTimeConv::StringToTime(const char* tempStr)
{
    SetParseChars(":");
    CopyString(parsedStr, tempStr, maxStrLen);
    PrepareParseString(parsedStr, parseChars);

    hour = GetNextInt();
    minute = GetNextInt();
    second = GetNextInt();

    return DateOK();
}
Пример #3
0
 ActionType GetNextAction() {
     int value = GetNextInt();
     
     if(value <= ALLOCATE_THRESHOLD) {
         return ActionType::Allocate;
     }
     else if((value - ALLOCATE_THRESHOLD) <= DEALLOCATE_THRESHOLD) {
         return ActionType::Deallocate;
     }
     else return ActionType::Pass;
 }
Пример #4
0
//==============================================================================
//
// main
//
//==============================================================================
int main(int argc, char **argv)
{
    int numDisks = GetNextInt();
    int numPegs = GetNextInt();
    std::vector<int> startState;
    std::vector<int> endState;

    for (int i = 0; i < numDisks; i++)
    {
        startState.push_back(GetNextInt()-1);
    }

    for (int i = 0; i < numDisks; i++)
    {
        endState.push_back(GetNextInt()-1);
    }

    Graph *graph = new Graph(numDisks, numPegs);

    int numMoves = graph->BuildAndExplore(startState, endState);
    std::cout << "num moves = " << numMoves << std::endl;

    Graph::Vertex *vtx = graph->GetVertex(endState);
    std::list<Graph::Vertex *> forwardList;
    for (int i = 0; i < numMoves; i++)
    {
        forwardList.push_front(vtx);
        vtx = vtx->predecessor;
    }

    std::cout << numMoves << std::endl;
    std::list<Graph::Vertex *>::iterator iter;
    for (iter = forwardList.begin(); iter != forwardList.end(); iter++)
    {
        PrintMove(*iter); 
    }

    delete graph;

    return 0;
}
Пример #5
0
 int GetNextInt(int maxValue) {
     return GetNextInt() % maxValue;
 }
Пример #6
0
 int GetNextObjectSize() {
     int value = GetNextInt();
     return MIN_OBJECT_SIZE + (value % (MAX_OBJECT_SIZE - MIN_OBJECT_SIZE));
 }