int main( ) { char filename[FILENAME_MAX]; int choice; CPUTimer ct; cout << "Filename >> "; cin >> filename; do { choice = getChoice(); ct.reset(); switch( choice ) { case 1: RunList( filename ); break; case 2: RunCursorList( filename ); break; case 3: RunStackAr( filename ); break; case 4: RunStackLi( filename ); break; case 5: RunQueueAr( filename ); break; case 6: RunSkipList( filename ); break; } cout << "CPU time: " << ct.cur_CPUTime() << endl; } while( choice > 0 ); return 0; }
int main() { char a[1000]; cout << "Filename >> "; cin >> a; int choice; CPUTimer ct; do { cout << endl; choice = getChoice(); ct.reset(); switch (choice) { case 1: RunList(a); break; case 2: RunCursorList(a); break; case 3: RunStackAr(a); break; case 4: RunStackLi(a); break; case 5: RunQueueAr(a); break; case 6: RunSkipList(a); break; } cout << "CPU time: " << ct.cur_CPUTime() << endl ; } while(choice > 0); }
int main(){ string filename; cout << "Filename >> "; cin >> filename; CPUTimer ct; //cpu timer instance int choice; do { choice = getChoice(); ct.reset(); switch (choice) { case 1: RunList(filename); break; case 2: RunCursorList(filename); break; case 3: RunStackAr(filename); break; case 4: RunStackLi(filename); break; case 5: RunQueueAr(filename); break; case 6: RunSkipList(filename); break; } //switch cout << "CPU time: " << ct.cur_CPUTime() << endl; } while(choice > 0); }
int main(int argc, char* argv[]) { short **map, **map2; int width, cityCount, pathCounts[50]; Coordinates *cityPos; Router *router; CPUTimer ct; readFile(argv[1], &map, &map2, &width, &cityPos, &cityCount); Coordinates **paths = new Coordinates*[cityCount]; for(int i = 0; i < cityCount; i++) { paths[i] = new Coordinates[width * width]; // maximum number of edges possible pathCounts[i] = 0; } ct.reset(); router = new Router(map, width); for(int i = 0; i < width; i++) delete [] map[i]; delete [] map; router->findRoutes((const Coordinates*) cityPos, cityCount, paths, pathCounts); double time = ct.cur_CPUTime(); int trainTime = checkRoutes(map2, cityPos, cityCount, paths, pathCounts, width, argc); cout << "CPU time: " << time << " Train time: " << trainTime << endl; return 0; }
int main(int argc, char* argv[]) { Block *blocks; StreetSelecter *streetSelecter; int citySize, blockCount, numTrips, numWidened; Trip *trips, widenedBlocks[100]; char filename[80], command[80]; CPUTimer ct; if(argc != 2) { cout << "usage: RunCity.out CityFilename\n"; return 1; } ifstream inf(argv[1]); strcpy(filename, argv[1]); strtok(filename, "-"); strtok(NULL, "-"); numTrips = atoi(strtok(NULL, "-")); trips = new Trip[numTrips]; blocks = readFile(inf, citySize, blockCount, trips, numTrips); ct.reset(); streetSelecter = new StreetSelecter(blocks, blockCount, citySize, numTrips); delete [] blocks; streetSelecter->select(trips, numTrips, widenedBlocks, numWidened); // fills widenedBlocks cout << "CPU Time: " << ct.cur_CPUTime() << endl; writeSolution(argv[1], widenedBlocks, numWidened); // writes widenedBlocks to filename.ans sprintf(command,"./RunTrips.out %s", argv[1]); system(command); // runs trips of file using original and widened streets return 0; }
int main(int argc, char **argv) { int operationCount, count; short scores[600]; const Operation *operations; operations = readFile(argv[1], &operationCount); CPUTimer ct; ct.reset(); GradeBook *gradeBook = new GradeBook(); if(argv[2][0] != '0') runTests(gradeBook, operations, operationCount); else { for(int i = 0; i < operationCount; i++) { switch(operations[i].type) { case LIST_STUDENT : gradeBook->listStudent(operations[i].CRN, operations[i].SID, &count, scores); break; case ADD_STUDENT : gradeBook->addStudent(operations[i].CRN, operations[i].SID); break; case REMOVE_STUDENT : gradeBook->removeStudent(operations[i].CRN, operations[i].SID); break; case UPDATE: gradeBook->update(operations[i].CRN, operations[i].title, operations[i].SID, operations[i].score); break; case LIST_ASSIGNMENT : gradeBook->listAssignment(operations[i].CRN, operations[i].title, &count, scores); break; case ENTER_SCORES : gradeBook->enterScores(operations[i].CRN, operations[i].title, operations[i].scores); break; case ADD_ASSIGNMENT : gradeBook->addAssignment(operations[i].CRN, operations[i].title, operations[i].maxScore); break; case ADD_COURSE : gradeBook->addCourse(operations[i].CRN); for (int j = 0; j < operations[i].count ; j++ ) gradeBook->addStudent(operations[i].CRN, operations[i].SIDs[j]); break; } // switch } // for i } // else no tests cout << "CPU Time: " << ct.cur_CPUTime() << endl; return 0; } // main()
int main(int argc, char* argv[]) { ifstream inf(argv[1]); int generations, pairs, queryCount, familyCount; char dummy; inf >> generations >> dummy >> pairs >> dummy >> queryCount; inf.ignore(10, '\n'); Family *families = new Family[200000]; Query *queries = new Query[queryCount]; Person *answers = new Person[queryCount]; Person *answerKeys = new Person[queryCount]; readQueries(inf, queries, answerKeys, queryCount); familyCount = readFamilies(inf, families); CPUTimer ct; ct.reset(); FamilyTree *familyTree = new FamilyTree(families, familyCount); delete [] families; familyTree->runQueries(queries, answers, queryCount); cout << "CPU Time: " << ct.cur_CPUTime() << endl; for(int i = 0; i < queryCount; i++) if(answerKeys[i].year == -1) { if(answers[i].year != -1) { cout << "You found an ancestor when there was none on query #" << i << endl; cout << "Descendent 1: " << queries[i].person1.year << ' ' << queries[i].person1.lastName << ',' << queries[i].person1.firstName << endl; cout << "Descendent 2: " << queries[i].person2.year << ' ' << queries[i].person2.lastName << ',' << queries[i].person2.firstName << endl; cout << "Your answer:" << answers[i].year << ' ' << answers[i].lastName << ',' << answers[i].firstName << endl; } } else // An ancestor should be found if(answers[i].year != answerKeys[i].year || strcmp(answers[i].lastName, answerKeys[i].lastName) != 0 || strcmp(answers[i].firstName, answerKeys[i].firstName) != 0 || answers[i].gender != answerKeys[i].gender) { cout << "Disagreement on query #" << i << endl; cout << "Descendent 1: " << queries[i].person1.year << ' ' << queries[i].person1.lastName << ',' << queries[i].person1.firstName << endl; cout << "Descendent 2: " << queries[i].person2.year << ' ' << queries[i].person2.lastName << ',' << queries[i].person2.firstName << endl; cout << "Proper answer: " << answerKeys[i].year << ' ' << answerKeys[i].lastName << ',' << answerKeys[i].firstName << endl; cout << "Your answer:" << answers[i].year << ' ' << answers[i].lastName << ',' << answers[i].firstName << endl; } return 0; } // main()
int main(int argc, char *argv[]) { DiskDrive diskDrive; diskDrive.readFile(argv[1]); CPUTimer ct; currentRAM = maxRAM = 0; ct.reset(); new Defragmenter(&diskDrive); cout << "CPU Time: " << ct.cur_CPUTime() << " Disk accesses: " << diskDrive.getDiskAccesses() << " RAM: " << maxRAM << endl; diskDrive.check(); return 0; } // main
int main (int argc, char** argv) { CPUTimer ct; int choice; char filename[79]; cout << "Filename: "; cin >> filename; do { choice = getChoice(); ct.reset(); switch (choice) //Switch statement based on user's choice { case 1: RunList(filename); break; case 2: RunCursorList(filename); break; case 3: RunStackAr(filename); break; case 4: RunStackLi(filename); break; case 5: RunQueueAr(filename); break; case 6: RunSkipList(filename); break; } // end switch cout << "CPU time: " << ct.cur_CPUTime() << endl; } while (choice > 0); //end doWhile return 0; }//main
int main(int argc, char** argv) { int numTrips, numFlights, numCities; Flight *flights, *flights2; Trip *trips; readFile(&flights, &trips, &numTrips, &numFlights, &numCities, argv[1], &flights2); Itinerary *itineraries = new Itinerary[numTrips]; CPUTimer ct; Router *router = new Router(numCities, numFlights, flights2); delete [] flights2; for(int i = 0 ; i < numTrips; i++) router->findRoute((const Trip*) &trips[i], &itineraries[i]); cout << "CPU Time: " << ct.cur_CPUTime(); checkRoutes(flights, trips, numTrips, numFlights, itineraries, argc, argv); return 0; } // main()
int main(int argc, char** argv) { int numOperations, numInserts; const char *result; Operation *operations; CPUTimer ct; initializeNew(); // determines if malloc uses 1 or 2 ints for size. SongInfo *songInfos = new SongInfo[1000000]; readTrackFile(songInfos); SongInfo2 *songInfos2 = readSalesFile(argv[1], &numInserts, &numOperations, songInfos, &operations); ct.reset(); Sales *sales = new Sales(songInfos2, numInserts); delete [] songInfos2; maxRAM = currentRAM; // eliminated the songInfos2 size for(int i = 0; i < numOperations; i++) { // if(i == 465) // cout << i << endl; if(operations[i].operation == 'A') { result = sales->artistList( songInfos[operations[i].indices[0]].artist, operations[i].indices[1]); checkResult(result, songInfos[operations[i].indices[2]].trackID, i); } // if artistList else // purchase { result = sales->purchase( songInfos[operations[i].indices[0]].song, songInfos[operations[i].indices[0]].artist, songInfos[operations[i].indices[1]].song, songInfos[operations[i].indices[1]].artist, operations[i].indices[2]); checkResult(result, songInfos[operations[i].indices[3]].trackID, i); } // else purchae } // for each operation cout << "CPU Time: " << ct.cur_CPUTime() << " maxRAM: " << maxRAM << endl; return 0; } // main())
int main(int argc, char* argv[]) { char c; int numStations, numCars, numActions; Action *actions = new Action[1000000]; ifstream inf(argv[1]); inf >> numStations >> c >> numCars; Station *stations = new Station[numStations]; Station *stations2 = new Station[numStations]; Car *cars = new Car[numCars]; readFile(inf, stations, numStations, numCars, cars); memcpy(stations2, stations, sizeof(Station) * numStations); CPUTimer ct; Train *train = new Train(stations, numStations); delete [] stations; train->run((const Car*) cars, numCars, actions, &numActions); double time = ct.cur_CPUTime(); int totalDistance = checkActions(actions, numActions, stations2, numStations,cars, numCars); cout << "CPU time: " << time << " Total distance: " << totalDistance << endl; return 0; } // main()
int main(){ ifstream inputFile; //char strin[20]; char fileName[20]; char iord; int number; int choice; CPUTimer ct; cout << "Filename >> "; cin >> fileName; inputFile.open(fileName); do { choice = getChoice(); ct.reset(); //string dummy; //getline(thestream, dummy); //for(int i = 0; i < 10; i++){ //thestream >> iord >> number; //cout << iord; //cout << number << endl; //} //PassStream(inputFile); //RunList(); switch(choice) { case 1: RunList(inputFile); break; case 2: RunCursorList(inputFile); break; case 3: RunStackAr(inputFile); break; case 4: RunStackLi(inputFile); break; case 5: RunQueueAr(inputFile); break; case 6: RunSkipList(inputFile); break; } cout << "CPU time: " << ct.cur_CPUTime() << endl; }while(choice > 0); return 0; }
int main(int argc, char **argv) { char word[MAX_LENGTH + 1], matchingWords[100][MAX_LENGTH + 1]; int numWords, count; DictionaryWord *words = readWordsFile(); MatchingWords *matchingWordsKey = readTesterFile(argv[1], &numWords); CPUTimer ct; Checker *checker = new Checker((const DictionaryWord*) words, NUM_WORDS); delete words; for(int i = 0; i < numWords; i++) { strcpy(word, matchingWordsKey[i].word); checker->findWord(word, matchingWords, &count); if(count != matchingWordsKey[i].count) { cout << "Incorrect count for trial# " << i << " for " << matchingWordsKey[i].word << " should be " << matchingWordsKey[i].count << " but received " << count << endl; } else // correct count { for(int j = 0; j < count; j++) if(strcmp(matchingWordsKey[i].matches[j], matchingWords[j]) != 0) { cout << "Words don't match for trial# " << i << " for " << matchingWordsKey[i].word << " match# " << j << " should be " << matchingWordsKey[i].matches[j] << " but received " << matchingWords[j] << endl; } // if invalid match } // else correct count } // for each word cout << "CPU Time: " << ct.cur_CPUTime() << endl; return 0; }
int main() { int choice; char filename[100]; int i = 0, k = 0, m = 0; cout << "Filename >> "; cin.getline(filename,100); CPUTimer ct; do { choice = getChoice(); ct.reset(); switch(choice) { case 1: // RunList(filename); { RunList(filename); break; } case 2: //RunCursorList(filename); { RunCursorList(filename); break; } case 3: //RunStackAr(filename); { RunStackAr(filename); break; } case 4: //RunStackLi(filename); { RunStackLi(filename); break; } case 5: //RunQueueAr(filename); { RunQueueAr(filename); break; } case 6: //RunSkipList(filename); { RunSkipList(filename); break; } } cout << "CPU time: " << ct.cur_CPUTime() << endl; }while(choice > 0); return (0); }