Exemplo n.º 1
0
void do_it(FILE *p)
{
	prq *pq;
	pq = malloc(1000*sizeof(prq));
	int mode = read(p);
	while(mode != 0)
	{
		if(mode == 1)
		{
			int daat = read(p);
			int prrri = read(p);
			pq = insert(pq,prrri,daat);
		}
		if(mode ==2)
		pq = removee(pq);
		if(mode == 3)
		peek(pq);
		if(mode ==4)
		{
			int daat = read(p);
			int newp = read(p);
			pq = increase_pri(pq,daat,newp);
		}
		mode = read(p);
	}
}
Exemplo n.º 2
0
int main(void){
    scanf("%d",&testPoints);
    for(i=0;i<testPoints;i++){
       scanf("%d",&remains);
       if(remains){
           have[j]=remains;
           pos[j]=i;
           total += remains;
           j++;
       }
    }
   printf("j:%d\n",j);
    while(total--){
       removee(current);
       temp = findNext(current);
       printf("\nj: %d temp: %d pos: %d\n",j,temp,pos[temp]);
       dest = pos[temp] - pos[current] > 0 ? pos[temp] - pos[current] : pos[current] - pos[temp];
      // printf("\ndest: %d\n",temp);
       //for(k=0;k<temp;temp++)putchar('R');
       current = temp;
       putchar('P');
    }
    putchar('\n');
    return 0;
}
Exemplo n.º 3
0
void test_should_not_remove_element_from_the_list(){
	void* res;
	Intern kavita = {111,"kavita",18};
	Intern prajakta = {110,"prajakta",19};
	insert(internsPtr, 0, &prateek);
	insert(internsPtr,1,&kavita);
	insert(internsPtr,2,&prajakta);
    res = removee(internsPtr,3);
	ASSERT(NULL == res);
}
Exemplo n.º 4
0
int main(int argc, char *argv[]) {
	int choice;
	int value;
	int index;
	while(1) {
		printf("What do you want to do?\n\n");
		printf("1. Insert \n2. Fetch \n3. display \n4. Remove\n5. Exit\n");
		scanf("%d", &choice);
		
		switch(choice) {
			case 1:
				printf("\nEnter the value you want to insert!\n");
				scanf("%d", &value);
				insert(value);
				printf("\nInserted the value %d into linkedList\n", value); 
				break;
			case 2:
				printf("\nValue at what index you want to fetch\n");
				scanf("%d", &index);
				value = fetch(index);
				printf("\nValue at index %d is %d\n", index, value); //need to fetch real value
				break;
			case 3:
				
				display();
                break;
            case 4:
            removee();
            break;
           case 5:
                   printf("\nExiting...\n"); 
                  exit(0);   
			default:
				break;
		}
	}
}