Example #1
0
int main (int argc, char *argv[])
{
    int *list, i, noio=0, noinit=0;
    int length=LENGTH;
    char mode='b';
    char *usage="Usage: prefixSum -(basic|sweep|1tiled|2tiled|cacheob|parallel) [-n <dimension>] [-s1 tilesize] [-s2 tilesize] [-noIO] [-noinit]\n";

    for (i=1; i<argc; i++) {
        if (!strcmp("-n", argv[i])) {
            sscanf(argv[++i], "%d", &length);
        } else if (!strcmp("-noIO", argv[i]) || !strcmp("-noio", argv[i])) {
            noio=1;
        } else if (!strcmp("-noinit", argv[i])) {
            noinit=1;
        } else if (!strcmp("-n", argv[i])) {
            sscanf(argv[++i], "%d", &length);
        } else if (!strcmp("-basic", argv[i])   ||
                   !strcmp("-sweep", argv[i])   ||
                   !strcmp("-1tiled", argv[i])  ||
                   !strcmp("-2tiled", argv[i])  ||
                   !strcmp("-cacheob", argv[i]) ||
                   !strcmp("-parallel", argv[i])) {
            mode=argv[i][1]; //mode = 'b', 's', '1', '2', 'c' or 'p'
        }
    }
    list = generateList(length, noinit);
    

    
    if (!noio) {
        printf("Original list\n");
        displaylist(list, length);
    }
    
    switch (mode) {
        case 'b':
            prefixSum(list, length);
            break;
        case 's':
            prefixSumSweep(list, length);
            break;
        case 'c':
            prefixSumCacheObl(list, length);
            break;
        default:
            printf("Option not recognized.\n");
            printf("%s", usage);
            break;
    }
    
    if (!noio) {
        printf("Prefix sum list\n");
        displaylist(list, length);
    }
}
//Main Function
int main()
{
	nodeptr list;
	list= NULL;
	insertatfirst(&list, 6);
	insertatfirst(&list, 5);
	insertatfirst(&list, 4);
	printf("The linked list is:\n");
	displaylist(list);
	printf("The deleted item is:\n %d", deletefromfront(&list));
	printf("\nThe linked list is:\n");
	displaylist(list);
}
Example #3
0
int main()
{
	nodeptr p;
    p=NULL;
    insertatfirst(&p,5);
    insertatfirst(&p,6);  
    insertatfirst(&p,7); 
    displaylist(p);
	printf("deleted=%d\n",deletefromfront(&p));
	printf("deleted=%d\n",deletefromfront(&p));
	printf("deleted=%d\n",deletefromfront(&p));
	printf("deleted=%d\n",deletefromfront(&p));
		  
    displaylist(p); 
}
Example #4
0
int main()
{
	nodeptr list;
	list = NULL;
	insertatfirst(&list,5);
	insertatfirst(&list,6);
	insertatfirst(&list,7);
	insertatfirst(&list,8);
	insertatfirst(&list,9);
	insertatfirst(&list,10);
	displaylist(list);
	printf("deleted=%d\n",deletefromfront(&list));
    printf("deleted=%d\n",deletefromfront(&list));
	displaylist(list);
}
Example #5
0
void dbeg()
{
p=head;
head=head->next;
free(p);
displaylist(head);
}
void main()
{
        NODE header,rev;
        header=createempty();
        getinputs(5,header);
        displaylist(header);
        rev=reverselist(header);
}
Example #7
0
int main( )
{
	getdata( ) ;
	printf ( "Linked List Before Sorting:\n" ) ;
	displaylist( ) ;

	selection_sort( ) ;
	printf ( "Linked List After Selection Sorting:\n" ) ;
	displaylist( ) ;

	getdata( ) ;
	printf ( "Linked List Before Sorting:\n" ) ;
	displaylist( ) ;

	bubble_sort( ) ;
	printf ( "Linked List After Bubble Sorting:\n" ) ;
	displaylist( ) ;
	return 0 ;
}
Example #8
0
void main(){

 struct cl *c=insertnode(NULL,2);
 insertnode(c,5);
 insertnode(c,8);
 insertnode(c,9);

 displaylist();

}
int calculateDisplacements(int mat[SIZE1][SIZE2],int * disps)
{
	int n1,n2,x1,y1,count; 
	struct coordinate listones[MAXONES];
	count=0; 
	for(n1=0; n1<SIZE1; n1++)
	{
		for(n2=0; n2<SIZE2; n2++)
		{
			if(mat[n1][n2]==1)
			{
				listones[count].x=n1; 
				listones[count].y=n2; 
				count++;
			} 
		}
	} 
	displaymatrix(mat,NULL); 
	displaylist(listones,count); 
	
	for(n1=0; n1<SIZE1; n1++)
	{
		for(n2=0; n2<(2*SIZE2-1); n2++)
		{
			disps[n1*(2*SIZE1-1)+n2]=0; 
		}
	}	
	
	for(n2=0; n2<count; n2++)
	{
		for(n1=0; n1< n2; n1++)   //entry in counter-1 position is newest 1, we need to verify its displacement with the older ones is not already in the matrix
		{
			y1=listones[n2].y-listones[n1].y; 
			x1=listones[n2].x-listones[n1].x; 
			if(x1<0)  //only half of displacements are unique, we use this convention to pick half
			{
				x1=x1*-1; //just inverting lines, b/c displacements unique up to inversion
				y1=y1*-1; 
			} 
			y1=y1+SIZE2-1; 
		
			//printf("next displacement added %d %d \n",x1,y1); 
			disps[x1*(2*SIZE2-1)+y1]++;
		}
	}
	return 0; 
}
Example #10
0
main(int argc, char *argv[])
{
  if (argc != 3){
    fprintf (stderr, "Usage:%s <host> <port>\n",
            argv[0]);
  }
  
  int pid = fork();
  
  if(pid!=0) {
    enter(argv);
    
    char b[60];
  
    while(1) {
      system("clear");
      printf("1. Get list of files\n2. Request video\n3. Exit\n");
      gets(b);
      if(strcmp("1", b)==0) {
	displaylist(argv);
      }
      else if(strcmp("2", b)==0) {
	printf("Enter the name of the file to request\n");
	gets(b);
	printf("Getting the list of IPs\n");
	getips(argv, b);
      }
      else if(strcmp("3", b)==0) {
	break;
      }
      else {
	printf("Invalid arguement.\nPress any key to continue...");
	gets(b);
      }
    }
    stopstreamserver();
    exit1(argv);
  }
  else {
    startstreamserver();
  }
}
Example #11
0
void start()
{
    
	char ch,ch1;
	loads();
	cout<<"\t\t\t\t\t\t\tWELCOME TO MANAGER MODE\n\t\t\t\t\t\t\t_______________________\n\n\n";
    createlist();
    chooseteam(); 
    createplayerlist();
    cout<<"\nPlease enter the manager details\n\n";
    t[I].get2();
    cout<<"\n\nTEAM AND MANAGER DETAILS\n________________________\n\n";
    t[I].disp3();
    t[I].disp1();
    t[I].disp2();
    
    cout<<"\nAre you ready to begin(y/n):";
	cin>>ch;
	cout<<"\n\n\nPLAYER LIST\n___________\n\n";
	  
    if(ch=='y')
	{
        displaylist();   
        chooseplayers();
        if(t[I].rem<=0)
        {
            cout<<"\n\nOOPS!! You are out of cash\n YOU'RE FIRED FROM THE JOB";
            cout<<"\nDo you want to try again (y/n):";
            cin>>ch;

            if(ch=='y')
            {
                system("cls");
                for(int k=0;k<8;k++)
                {
                    t[k].rem=60000;
                    t[k].points=0;
                    t[k].w=0;
                    t[k].l=0;
                    t[k].d=0;
                }
                main();
            }
                                   
            else if(ch=='n')
                exit(0);
            
            else
            {
                cout<<"Invalid.Enter again:";
                cin>>ch;
                    
                if(ch=='y')
                {
                    system("cls");
                    for(int k=0;k<8;k++)
                    {
                        t[k].rem=60000;
                        t[k].points=0;
                        t[k].w=0;
                        t[k].l=0;
                        t[k].d=0;
                    }
                    main();
                }

                else if(ch=='n')
                    exit(0);
            }
        }
Example #12
0
int main()
{
//clrscr();
int n=1,l=0,choice;
printf("enter how many elements u want to enter\n\t");
scanf("%d",&n);
head=createlist(n);
while(1)
{
 printf("\n1.insert at begning");
 printf("\t2 insert at last");
 printf("\t3 insert at position");
 printf("\n4 display");
 printf("\t5 search");
 printf("\t6 delete at specfic position");
 printf("\n7 delete at last\t");
 printf("\t8 delete at begning");
 printf("\t9 swap");
 printf("\n10 conactenate lists");
 printf("\n11 exit\t");
 scanf("%d",&choice);
 switch(choice)
{
case 1:
inatbeg();
displaylist(head);

break;
case 2:
inlast();
displaylist(head);
break;
case 3:
nyp();
displaylist(head);
break;
case 4:
displaylist(head);
break;
case 5:
l=search(head);
if(l!=-1)
printf("\t\t key  found at position %d  \t",l);
else
printf("\t\t sory value not found \n");
break;
case 6:
int p;
printf("\n enter positi0n to delete\t");
scanf("%d",&p);
dnode(p);
displaylist(head);
break;
case 7:
dlast();
displaylist(head);
break;
case 8:
dbeg();
break;
case 9:
swap(head);
displaylist(head);
break;
case 10:
//concatenate();
break;
case 11:
exit(0);
break;
deafault:
printf("\n enter valid choice\n");
}
}
getch();
}