void main()
{
    int item;
    printf("enter the value to be insert into the list:\n");
    scanf("%d",&item);
    inserting(item);
    display();

}
Пример #2
0
void main()
{
    int item,loc;
    printf("Enter the value to be insert into the list:\n");
    scanf("%d",&item);
    printf("Enter the location at which %d to be inserted:\n",item);
    scanf("%d",&loc);
    inserting(item,loc);
    display();

}
Пример #3
0
int main(int argc, char const *argv[])
{
    struct Table T1;
    init(&T1);
    bool output;
    for (int i = 0; i < 10; i++) {
        output = inserting(i, &T1);
    }
    output = delete(5, &T1);
    output = delete(1, &T1);
    output = lookup(5, &T1);
    return 0;
}
void main()
{
    int item, i=1,n;
    printf("        Linked List\n        ===========");
    do
    {
      printf("\nEnter your choice..\n1.Insert a node  \n2.Display \n3.Search a element \n4.Exit\n");
      scanf("%d",&n);
      switch(n)
      {
          case 1:inserting();break;
          case 2:display();break;
          case 3:search();break;
          case 4:i=0;
      }
    }
    while(i==1);
}
int RBS(const exlcm_sync_t * msg)
/*****************************************************************************
*   Input    :
*   Output   :
*   Function :
******************************************************************************/ 	
{
	struct timeval tv;			// create timestruct
	exlcm_sync_t my_data;		// create a struct to LCM
	
	switch(msg->operation)		// statemachine of handling LCM packets
		{
			case BEACONSENDER:	// case when beacon message is recieved	
				tv = get_localrealtime();	// get timestamp for received packets
				rbs.realtime = (double)tv.tv_sec + (double)tv.tv_usec / (double)1000000;	// calculate time in sec
				my_data = construct_msg(NODE,ALL_NODES,RECIEVER_TO_RECIEVER,rbs.realtime); // define send struct
				exlcm_sync_t_publish(lcm, SYNC_CHANNEL, &my_data);		// publish the struct
				print_info(msg);				// print all approprivately informations
				break;	
			case RECIEVER_TO_RECIEVER:	// case when nodes inform each other
				if(msg->sender != NODE)   		// ONly run RBS for others nodes  
				{
					//printf("---------------- RECEIVER TO REVEVER SENDER ------------------------\n");
					handle_linkedlist(msg);		// handle list with packets
					
					if(inserting(msg, REMOTETIME, sample_remoterealtime(msg))) // inserting time for remote nodes
						printf("FAILURE IN INSERTING REMOTETIME \n");
					
					if(getting(msg, DATASIZE, ZERO) == ZERO & rbs.nodes[msg->sender].reach_max == ZERO)	// this is also run the first time
					{
						rbs.realtime_0 = rbs.realtime;		// first time for current stored
						if(inserting(msg, LOCALTIME, 0))	// store realtime in nodes
							printf("FAILURE IN INSERTING REMOTETIME first run \n");	
					}
					else
					{
						if(inserting(msg, SCALETIME, rbs.realtime - rbs.realtime_0))	// store scalerealtime in nodes
							printf("FAILURE IN INSERTING SCALETIME \n");		
					}
					
					if(inserting(msg, LOCALTIME, rbs.realtime))	// store realtime in nodes
							printf("FAILURE IN INSERTING REALTIME \n");	
					
					if(inserting(msg, OFFSET, sample_remoterealtime(msg) - rbs.realtime))		// store offset (remote - current)
						printf("FAILURE IN INSERTING OFFSET \n");
					
					
					
					mean_offset(rbs.nodes[msg->sender].end);		// calculate meanoffset
					if(rbs.nodes[msg->sender].end->next != NULL)	// skip first sample
						leastsquarelinarregression(rbs.nodes[msg->sender].end);	// calculate leastsquareregression
					
					//printf("----------------END RECEIVER TO REVEVER SENDER ------------------------\n");
					
					print_info(msg);				// print all approprivately informations
					rbs.nodes[msg->sender].n++;		// count x increment
					
				}
				break;
			default:
				break;
			}
	return 0;
}