int main(int argc, char const *argv[]) { int n=0; int hua=1,fangxiang=0; int moveStep=0; int cmdtemp; int draw=0; int cmd[40]={2,524,3,524,4,512,4,506,4,506,4,503,3,516,4,509,4,508,4,507,1,6,9}; while(cmd[n]!=9){ cmdtemp=cmd[n]; // while(cmdtemp!=9){ // scanf("%d",&cmdtemp); if(cmdtemp==1){ hua=1; }else if(cmdtemp==2){ hua=2; } if(cmdtemp==3){ fangxiang=3; }else if(cmdtemp==4){ fangxiang=4; } if(cmdtemp>499){ draw=5; moveStep=cmdtemp%100; setarray(hua,fangxiang,moveStep); } if(cmdtemp==6){ print(); } draw=0; n++; } return 0; }
void getpars(char *procparfile,struct data *d) { /* Null the data structure */ nulldata(d); /* Copy procpar filename */ if ((d->procpar = (char *)malloc((strlen(procparfile)+1)*sizeof(char))) == NULL) nomem(__FILE__,__FUNCTION__,__LINE__); strcpy(d->procpar,procparfile); /* Get the parameters, some attributes, and their values */ getprocparpars(procparfile,&d->p); /* Set and fill the 'pars' array structure. We convert array to an array of pars in the 'pars' array structure. We also figure how often each par cycles as the expt is run */ setarray(&d->p,&d->a); /* Convert sviblist to an array of pars in the 'pars' sviblist structure */ list2array("sviblist",&d->p,&d->s); }
int main() { //Print initial array printf("\n//=====Shuffled array===================//"); setarray(); printarray("Initial Array"); //=====Simple sorts=====// printf("\n\n//=====Simple sorts====================//"); //Insertion sort setarray(); insertionSort(array,10); printarray("InsertionSort"); //Selection sort setarray(); selectionSort(array,10); printarray("SelectionSort"); //=====Eficient Sorts=====// printf("\n\n//=====Eficient sorts==================//"); //Mergesort setarray(); mergeSort(array,0,9,10); printarray("MergeSort"); //Heapsort setarray(); heapSort(array,10); printarray("HeapSort"); //Quicksort setarray(); quickSort(array,0,9); printarray("QuickSort"); //Bubble sort and variants printf("\n\n//=====Bubble sort and variants========//"); //Bubblesort setarray(); bubbleSort(array,10); printarray("BubbleSort"); //Shellsort setarray(); shellSort(array,10); printarray("ShellSort"); //Combsort setarray(); combSort(array,10); printarray("CombSort"); //Distribution sorts printf("\n\n//=====Distribution sorts==============//"); //Countingsort setarray(); countingSort(array, 10, 0, 99); printarray("CountingSort"); //Radixsort setarray(); radixSort(array, 10); printarray("RadixSort"); //Other sorts printf("\n\n//=====Other sorts=====================//"); //Gnomesort setarray(); gnomeSort(array,10); printarray("GnomeSort"); //Cyclesort setarray(); cycleSort(array,10); printarray("CycleSort"); printf("\n\n"); }
void readsysdefaults(void) { int i,j; FILE *f; char buf[200]; char *s; /* Setup defaults. */ setarray ( &sysdefplanets, 0 ); startplanets[0]=startplanets[10]=startplanets[20]=startplanets[30]=1; setarray ( &sysdefships, 1 ); setarray ( &sysdefweapons, 1 ); testtime= -1; topgun=0; /* added 12/9/90 TC */ newturn=0; /* added 1/20/91 TC */ hiddenenemy=1; binconfirm=0; plkills=2; ddrank=0; garank=0; sbrank=3; chaosmode=0; tournplayers=5; udpAllowed=1; /* UDP */ top_armies = 30; /* added 11/27/93 ATH */ planet_move = 0; /* added 9/28/92 NBT */ wrap_galaxy = 0; /* added 6/28/95 JRP */ pingpong_plasma = 0; /* added 7/6/95 JRP */ #ifdef MINES mines = 0; /* added 8/3/95 JRP */ #endif twarpMode = 0; twarpSpeed = 60; distortion = 10; fps = 50; maxups = fps; minups = 1; defups = maxups; manager_type = NO_ROBOT; strcpy(Motd,N_MOTD); strcpy(script_tourn_start, ""); strcpy(script_tourn_end, ""); getshipdefaults(); f=fopen(SysDef_File, "r"); if (f==NULL) { ERROR(1,("No system defaults file! Using coded defaults.\n")); return; } stat(SysDef_File, &oldstat); while (fgets(buf, 200, f)!=NULL) { if (buf[0] == '#') continue; /* a comment */ s=strchr(buf, '='); /* index marked as LEGACY in POSIX.1-2001 */ if (s==NULL) continue; *s='\0'; s++; /* check each keyword from file with our list of keywords */ for (j=0; sysdef_keywords[j].type != SYSDEF_END; j++) { /* check current keyword for a match */ if (strcmp(buf,sysdef_keywords[j].key)==0) { switch (sysdef_keywords[j].type) { case SYSDEF_INT: { int *p = (int *) sysdef_keywords[j].p; *p = atoi(s); } break; case SYSDEF_FLOAT: { float *p = (float *) sysdef_keywords[j].p; sscanf (s, "%f", p); } break; case SYSDEF_CHAR: sscanf(s,"%s", (char *) sysdef_keywords[j].p); break; case SYSDEF_ARRAY: { struct sysdef_array *a = sysdef_keywords[j].p; setarray(a, 0); readstrings(a->name, s, a->keys, a->p, a->max); } break; case SYSDEF_ROBOT: /* cast from pointer to integer of different size [ok] */ if (atoi(s)) manager_type = (int) sysdef_keywords[j].p; break; case SYSDEF_SHIP: shipdefs (atoi(s),f); break; } break; } } } /* Make sure every team can start at some planet! */ for (i=0; i<4; i++) { int k = 0; for (j=0; j<10; j++) { if (startplanets[i*10+j]) { k++; break; } } if (k == 0) { ERROR(1,("No starting planets specified for team %d\n", i)); startplanets[i*10]=1; } } /* apply minimum and maximum values here */ if (tournplayers == 0) tournplayers=5; if (ping_freq <= 0) ping_freq = 1; if (ping_iloss_interval <= 0) ping_iloss_interval = 1; if (ping_ghostbust_interval <= 0) ping_ghostbust_interval = 1; if (ghostbust_timer <= 0) ghostbust_timer = 1; #ifdef BASEPRACTICE if (manager_type == BASEP_ROBOT) { binconfirm=0; /* allow robots to join */ #ifdef ALLOW_PRACTICE_ROBOT_SB sbrank=0; /* no SB restriction */ #endif check_scum=0; } #endif if (manager_type == INL_ROBOT) { tournplayers=1; ddrank=0; /* no DD restriction */ garank=0; /* no GA restriction */ sbrank=0; /* no SB restriction */ killer=0; /* disable iggy for game */ surrenderStart=0; } fclose(f); }