int main() { int i, asize, check; unsigned int item; unsigned int copy[MAX]; create(); asize = 0; unsigned int s = nondet_unsigned_int(); __CPROVER_assume (s <= MAX); for (i=0; i<s; i++) { item = nondet_unsigned_int(); insert_by_priority(item); asize++; display_pqueue(); check = check_queue(pri_que, copy, asize); assert(check == 0); } return 0; }
//function to find goal from a given start point void findGoal(int start_x, int start_y, int goal_x, int goal_y){ int lowestx; int lowesty; init_map(); createopen(); insert_by_priority(node_map[start_y][start_x]); while(true){ get_lowest_f_cost(lowestx, lowesty); add_to_closed(lowestx, lowesty); if(is_goal(lowestx, lowesty,goal_x,goal_y)){ displayTextLine(2, "found path"); wait1Msec(100); //get_path(); get_distance(start_x, start_y, goal_x, goal_y); return; } //get neighbours get_neighbours(lowestx, lowesty); for(int i=0; i<CONNECTIVITY;i++){ if((current_neighbours[i].val==OBST)||(current_neighbours[i].onclosed==true)){} else if((current_neighbours[i].g>(get_g_cost(current_neighbours[i].x,current_neighbours[i].y,lowestx, lowesty)))|| current_neighbours[i].onopen==false){ set_cost(current_neighbours[i].x,current_neighbours[i].y,lowestx, lowesty); current_neighbours[i].parentx=lowestx; current_neighbours[i].parenty=lowesty; memcpy(&node_map[current_neighbours[i].y][current_neighbours[i].x],¤t_neighbours[i],sizeof(node_map[current_neighbours[i].y][current_neighbours[i].x])); if(current_neighbours[i].onopen==false){ insert_by_priority(current_neighbours[i]); } } } } }
void main() { int n, ch; printf("\n1 - Insert an element into queue"); printf("\n2 - Delete an element from queue"); printf("\n3 - Display queue elements"); printf("\n4 - Exit"); create(); while (1) { printf("\nEnter your choice : "); scanf("%d", &ch); switch (ch) { case 1: printf("\nEnter value to be inserted : "); scanf("%d",&n); insert_by_priority(n); break; case 2: printf("\nEnter value to delete : "); scanf("%d",&n); delete_by_priority(n); break; case 3: display_pqueue(); break; case 4: exit(0); default: printf("\nChoice is incorrect, Enter a correct choice"); } } }
void main() { int n, ch; printf("\n1 - Insert an element into queue"); printf("\n2 - Delete an element from queue"); printf("\n3 - Display queue elements"); printf("\n4 - Exit"); create(); for (int i = 0; i < 100; i++) { printf("\nEnter your choice : "); ch = i % 3 - 1; switch (ch) { case 1: printf("\nEnter value to be inserted : "); *(&n)=249; insert_by_priority(n); break; case 2: printf("\nEnter value to delete : "); *(&n)=935; delete_by_priority(n); break; case 3: display_pqueue(); break; case 4: exit(0); default: printf("\nChoice is incorrect, Enter a correct choice"); } } }