void maze_loop() { while (1) { if (maze.started) { PORTAbits.RA0=0; asm("nop"); maze.started=start_done; collect_sensor_data(); centering(); if (is_branch()) branching(); maze_debug(); } } }
int main() { int max = 5; // The maximum total amount of movies that you can store in your list load("Favorite_Movie_List.txt"); char ch = 'i'; ungetc('\n', stdin); // inject input buffer with a return character printf("Welcome to your favorite movie manager!\n\n"); do { printf("Please enter your selection:\n"); printf("\ta: add a new movie to your list\n"); printf("\td: display the movies in your list\n"); printf("\tq: quit and save your list\n"); flush(); // flush input buffer ch = tolower(getchar()); branching(ch, max); } while (ch != 113); save("Favorite_Movie_List.txt"); return 0; }
bool SingleMachineBB::run(Lisa_Schedule* pSchedule) { if(priority!=0){ Lisa_Vector<int>* order=new Lisa_Vector<int> (n); order->fill(0); if(Lisa_GraphAlg::topsort(priority,order)){ delete order; } else{ delete order; return false; } for(int i=0; i<n; i++){ (*Sources)[i]=priority->get_predecessors(i+1); } } else{ Sources->fill(0); } branching(); pSchedule->make_LR(); for(int i=0; i<n; i++){ (*pSchedule->LR)[(*bestSchedule)[i]][0]=i+1; } return true; }
int main() { char ch = 'i'; ungetc('\n', stdin); // inject input buffer with a return character printf("Welcome to the movie manager!\n\n"); do { printf("Please enter your selection\n"); printf("\ta: add a movie\n"); // added for hw07 printf("\tb: add an actor/actress to a movie\n"); printf("\tc: display a list of movies for an actor/actress\n"); printf("\td: delete all movies\n"); printf("\te: display all movies\n"); printf("\tf: display a movie by index\n"); printf("\tg: display a list of movies by genre\n"); printf("\tq: quit \n"); flush(); // flush input buffer ch = tolower(getchar()); branching(ch); } while (ch != 113); delete_all(list); // ADDED TO PREVENT MEMORY LEAKS _CrtDumpMemoryLeaks(); // ADDED TO CHECK FOR MEMORY LEAKS return 0; }
int main() { // print a menu for selection char ch = 'i'; ungetc('\n', stdin); // inject input buffer with a return character do { printf("Enter your selection\n"); printf("\ta: insert a new entry\n"); printf("\td: delete an entry\n"); printf("\tp: compute average\n"); printf("\tq: quit \n"); flush(); // flush input buffer ch = tolower(getchar()); // see tutorial branching(ch); } while (ch != 113); delete_list(head); return 0; }
int main() { char ch = 'i'; ungetc('\n', stdin); // inject input buffer with a return character printf("The size of the order structure is %d bytes.\n\n", sizeofOrderStructure()); do { printf("Enter your selection\n"); printf("\ti: insert a new order.\n"); printf("\tu: update an order.\n"); printf("\td: cancel an order.\n"); printf("\tp: process an order.\n"); printf("\tq: quit \n"); flush(); // flush input buffer ch = tolower(getchar()); // see tutorial branching(ch); } while (ch != 113); return 0; }
bool SingleMachineBB::branching(int k) { if(k<n){ int counter=0; Lisa_Vector<int>* s=new Lisa_Vector<int> (n); // count jobs, that are undone and // do not have any predecessors within the priority graph for(int i=0; i<n; i++){ (*s)[i]=(*Sources)[i]; if((!(*Done)[i])&&((*Sources)[i]==0)){ counter++; } } // compute lower bounds for all possible jobs Lisa_Vector<double>* lbs=new Lisa_Vector<double> (counter); for(int i=0, j=0; i<n; i++){ // choose only released undone jobs, without predecessors if((!(*Done)[i])&&((*Sources)[i]==0)){ (*Schedule)[k]=i; (*Done)[i]=true; if(priority!=0){ // decrement number of predecessors for every // connected job for(int h=0; h<n; h++){ if(h!=i){ if(Lisa_Graph::ARC==(priority->get_connection(i+1,h+1))){ (*Sources)[h]=(*Sources)[h]-1; } } } } //if(priority) // lower bound computation for choosen job // at k-th position in Schedule (*lbs)[j]=lb(k); // set up values for next lower bound computation for(int h=0; h<n; h++){ (*Sources)[h]=(*s)[h]; } (*Done)[i]=false; j++; } //if } // compare minimum of lower bounds // with lower bound of bestSchedule (bestLmax) bool speed=true; double minMax=(*lbs)[lbs->index_of_min()]; if((bestLmax<=minMax)&&(!FirstSchedule)){ return true; } // choose first job with minimum of lower bounds // and branch one step further for(int i=0, j=0; i<n; i++){ if((!(*Done)[i])&&((*Sources)[i]==0)&&speed){ if((*lbs)[j]==minMax){ //job=i; speed=mode; if(priority!=0){ // update predecessors for(int h=0; h<n; h++){ if(h!=i){ if(Lisa_Graph::ARC==(priority->get_connection(i+1,h+1))){ (*Sources)[h]=(*Sources)[h]-1; } } } } //if(priority) (*Schedule)[k]=i; (*Done)[i]=true; branching(k+1); for(int h=0; h<n; h++){ (*Sources)[h]=(*s)[h]; } (*Done)[i]=false; } //if(LowerBounds==minMax) j++; } //if } //for delete s; delete lbs; } //if k<n if(k==n){ newSchedule(); } return true; }