Exemple #1
0
void main()
{
  int item,ch,tot;

clrscr();

 do
 {

  clrscr();
  printf("\n\n1 for insert");
  printf("\n2 for Count the Total No of Nodes");
  printf("\n3 for exit");

  printf("\n\nEnter your choice:");
  scanf("%d",&ch);


  switch(ch)
  {
    case 1:  printf("\n\nEnter the item for the new node : ");
	     scanf("%d",&item);

	     if(head==NULL)
	     {
		 create_head(item);
	     }
	     else
	     {
		lastNode= insert(lastNode,item);
	     }

	     printf("\n\n%d is inserted .....",item);
	     getch();
	     break;

    case 2: tot=countNodes(head);
	    if(tot==0)
	    {
		printf("\n\nList is empty.....");
	    }
	    else
	    {
		printf("\n\nTotal no of nodes : %d",tot);
	    }
	    getch();
	    break;

    case 3 :exit(0);
  }

 } while(ch!=3);

}
  void mk_array_instantiation::instantiate_rule(const rule& r, rule_set & dest)
  {
    //Reset everything
    selects.reset();
    eq_classes.reset();
    cnt = src_manager->get_counter().get_max_rule_var(r)+1;
    done_selects.reset();
    ownership.reset();

    expr_ref_vector phi(m);
    expr_ref_vector preds(m);
    expr_ref new_head = create_head(to_app(r.get_head()));
    unsigned nb_predicates = r.get_uninterpreted_tail_size();
    unsigned tail_size = r.get_tail_size();
    for(unsigned i=0;i<nb_predicates;i++)
    {
      preds.push_back(r.get_tail(i));
    }
    for(unsigned i=nb_predicates;i<tail_size;i++)
    {
      phi.push_back(r.get_tail(i));
    }

    //Retrieve selects
    for(unsigned i=0;i<phi.size();i++)
      retrieve_selects(phi[i].get());

    //Rewrite the predicates
    expr_ref_vector new_tail(m);
    for(unsigned i=0;i<preds.size();i++)
    {
      new_tail.append(instantiate_pred(to_app(preds[i].get())));
    }
    new_tail.append(phi);
    for(obj_map<expr, var*>::iterator it = done_selects.begin(); it!=done_selects.end(); ++it)
    {
      expr_ref tmp(m);
      tmp = &it->get_key();
      new_tail.push_back(m.mk_eq(it->get_value(), tmp));
    }
    proof_ref pr(m);
    src_manager->mk_rule(m.mk_implies(m.mk_and(new_tail.size(), new_tail.c_ptr()), new_head), pr, dest, r.name());
  }
void main()
{
  int item,ch,pos,cnt=0;
  node *loc;

clrscr();

 do
 {

  clrscr();
  printf("\n\n1 for insert By position");
  printf("\n2 for display");
  printf("\n3 for exit");

  printf("\n\nEnter your choice:");
  scanf("%d",&ch);


  switch(ch)
  {
    case 1:  printf("\n\nEnter the position : ");
	     scanf("%d",&pos);

	     if(pos-1>cnt || pos-1<0)
	     {
	       printf("\n\nInvalid position ......!");
	       getch();
	     }
	     else
	     {

		     printf("\n\nEnter the item for the new node : ");
		     scanf("%d",&item);

		    if (head==NULL)
		    {
			 create_head(item);
		    }
		    else
		    {
			loc=search_by_pos(head,pos-1);
			insert_by_pos(loc,item);
		    }
		    cnt++;
		    printf("\n\n%d is inserted .....",item);
		    getch();
	     }
	     break;

    case 2: display(head);
	    getch();
	    break;


    case 3 :exit(0);
  }

 } while(ch!=3);

}