Beispiel #1
0
int main(){
int n=sizeof(a)/sizeof(a[0]);
  display_array(n);
quicksort(0,n-1);
 display_array(n);

return 0;
}
Beispiel #2
0
int main()
{
    int len = sizeof(a)/sizeof(a[0]);

    display_array(len);
    qsort(a, 0, len-1);
    display_array(len);

    return 0;
}
int main (void)
{					 
 	printf ("\nThe array before the sort: \n");
 	display_array (ARRAY_LENGTH, array);
 	
 	get_sort_type ();
 	
 	sort (array, ARRAY_LENGTH, sort_type);
 	
 	printf ("\nThe array after the sort: \n");
 	display_array (ARRAY_LENGTH, array);
 	
 	return 0;
}
Beispiel #4
0
void heapify(int a[20],int bound)
{
 int LR = 0; /* LR = 0 means left child and LR = 1 means right child */
 int max_val = 0, temp = 0;
 int i = 0;
 
 for(i=bound ; i>=0 ; i=i-2)
 {
        printf("\ni=%d\n",i);
        max_val = max(a[i],a[i+1]); /* Passing (left-child,right-right) always */
        printf("\nMAX-VAL:%d\n",max_val);

        if(a[i/2] < max_val)
        { printf("\nchild is greater than root\n");
          if(side) /* swap right with root */
            { printf("\nSwapping right\n"); 
              temp = a[i+1]; a[i+1] = a[i/2]; a[i/2] = temp; }
          else
            { printf("\nSwapping left\n");
              temp = a[i]; a[i] = a[i/2]; a[i/2] = temp; }

	}
        display_array(a);
 }
 
}
Beispiel #5
0
void quickSort(int * a, int low, int high){  
    int pos;  
    if(low < high){  
        pos = findPos(a, low, high); 
        display_array(low,high,a); 
        quickSort(a, low, pos-1);  
        quickSort(a, pos+1, high);  
    }  
}  
Beispiel #6
0
int main(){
	int i,k,n,arr[50];
	printf("Enter the value of n : \t");
	scanf("%d",&n);
	printf("Enter the array : ");
	read_array(arr,n);	
	insertion_sort(arr,n);
	display_array(arr,n);
}
int main()
{
	int *array;
	int total_count;
	
	printf("\t\t-------SELECTION SORTING-------\n");
	printf("Enter the numbers of elements to be added to array:");
	scanf("%d", &total_count);

    input_array(&array, total_count);

	printf("\nElements before sorting are:\n");
    display_array(array,total_count);

    selectionsort(array, total_count);

	printf("Elements after sorting are:\n");
    display_array(array,total_count);

	return 0;
}
Beispiel #8
0
int main()
{
 int i = 0 , N = 0 , n = 0 , input = 10 ;
// int a[20] = {15,20,25,16,4,9,13,17,12,50};
 int o[20] = {0};

/*
 printf("\nEnter the size of the elements(max=20):");
 scanf("%d",&input);
 n = input;


 printf("\nEnter the elements\n");
 for(i = 0; i<n ;i++)
  scanf("%d",&a[i]); 
*/

 n = input;

 if(whatAmI(n-1)) /* right */
 {
    printf("\nI am here\n");
    a[n] = 0;   /* Suppose all numbers > 0 */ 
    n = n-1;
 }

 
 for(i=0 ; i<n ; i++)
 {
    N = n-1;
    heapify(a,N);
    o[i] = a[0];
    a[0] = a[(input-1)-i];
    a[(input-1)-i] = o[i];
    display_array(a);
    if(whatAmI(n-1)) /* right */
    {
     printf("\nam here\n");
     n = n-2; 
    }
    else 
     n = n-2;
 } 


 printf("\nThe elements in des order is ...\n");
 for(i = 0; i<input ;i++)
  printf("%d ",o[i]);

 return 0;
}
Beispiel #9
0
int main(void){
char input[500] = "This is a big string.";
char output[500];
string array[100];

 for(int i=0;i<100;i++){  array[i] = NULL; }
 for(int i=0;i<500;i++){ output[i] = '\0';}                  
                       
split(input, array);
display_array(array);
reverse(array);
join(array, output);
printf("\n%s\n", output);
}
Beispiel #10
0
int main(int argc, char **argv)
{
	printf("quickSort\n");
	int len,i;
	int *array;
	printf("input count of number:");
	scanf("%d",&len);
	array=(int *)malloc(sizeof(int)*len);
	memset((void *)array,0,4*len);//初始化为0
	printf("input numbers:");
	for( i=0; i<len; i++)
	{
		scanf("%d",&array[i]);
	} 
	display_array(0,len,array);
	quickSort(array,0,len-1);
	free(array);
	return 0;
}
Beispiel #11
0
int main(void)
{
	int i = 0;
	printf("How many numbers would you like to sort:\t");
	scanf("%d", &array_size);
	
	array = (int *)malloc(array_size * sizeof(int));

	printf("Enter the numbers:\t");
	for(i = 0; i < array_size; i++)
	{
		scanf("%d", &array[i]);
	}

	//bubble_sort(&array, &array_size);
	// selection_sort(&array, &array_size);
	insertion_sort(&array, &array_size);
 	display_array(&array, &array_size);

	free(array);
}
Beispiel #12
0
PUBLIC void write_parameter_file(const char fname[]){
  FILE *outfp;
  int c;
  char *pnames[] = {"NP", "CG", "GC", "GU", "UG", "AU", "UA", " @"};
  char bnames[] = "@ACGU";
  outfp = fopen(fname, "w");
  if (!outfp) {
    fprintf(stderr, "can't open file %s\n", fname);
    exit(1);
  }
  fprintf(outfp,"## RNAfold parameter file v2.0\n");

  fprintf(outfp,"\n# %s\n", settype(S));
  fprintf(outfp,"/*  CG    GC    GU    UG    AU    UA    @  */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(stack37[c]+1,NBPAIRS,NBPAIRS, outfp);

  fprintf(outfp,"\n# %s\n", settype(S_H));
  fprintf(outfp,"/*  CG    GC    GU    UG    AU    UA    @  */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(stackdH[c]+1,NBPAIRS,NBPAIRS, outfp);

  fprintf(outfp,"\n# %s\n", settype(MMH));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchH37[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMH_H));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchHdH[k][i],5,5, outfp);

  }

  fprintf(outfp,"\n# %s\n", settype(MMI));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchI37[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMI_H));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchIdH[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMI1N));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatch1nI37[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMI1N_H));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatch1nIdH[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMI23));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatch23I37[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMI23_H));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatch23IdH[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMM));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchM37[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MMM_H));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchMdH[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MME));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchExt37[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(MME_H));
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++)
      display_array(mismatchExtdH[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# %s\n", settype(D5));
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(dangle5_37[c], 5, 5, outfp);

  fprintf(outfp,"\n# %s\n", settype(D5_H));
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(dangle5_dH[c], 5, 5, outfp);

  fprintf(outfp,"\n# %s\n", settype(D3));
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(dangle3_37[c], 5, 5, outfp);

  fprintf(outfp,"\n# %s\n", settype(D3_H));
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(dangle3_dH[c], 5, 5, outfp);


  /* dont print "no pair" entries for interior loop arrays */
  fprintf(outfp,"\n# %s\n", settype(INT11));
  { int i,k,l;
  for (k=1; k<NBPAIRS+1; k++)
    for (l=1; l<NBPAIRS+1; l++) {
      fprintf(outfp, "/* %2s..%2s */\n", pnames[k], pnames[l]);
      for (i=0; i<5; i++)
        display_array(int11_37[k][l][i], 5, 5, outfp);
    }
  }

  fprintf(outfp,"\n# %s\n", settype(INT11_H));
  { int i,k,l;
  for (k=1; k<NBPAIRS+1; k++)
    for (l=1; l<NBPAIRS+1; l++) {
      fprintf(outfp, "/* %2s..%2s */\n", pnames[k], pnames[l]);
      for (i=0; i<5; i++)
        display_array(int11_dH[k][l][i],5,5, outfp);
    }
  }

  fprintf(outfp,"\n# %s\n", settype(INT21));
  { int p1, p2, i, j;
  for (p1=1; p1<NBPAIRS+1; p1++)
    for (p2=1; p2<NBPAIRS+1; p2++)
      for (i=0; i<5; i++) {
        fprintf(outfp, "/* %2s.%c..%2s */\n",
                pnames[p1], bnames[i], pnames[p2]);
        for (j=0; j<5; j++)
          display_array(int21_37[p1][p2][i][j],5,5, outfp);
      }
  }

  fprintf(outfp,"\n# %s\n", settype(INT21_H));
  { int p1, p2, i, j;
  for (p1=1; p1<NBPAIRS+1; p1++)
    for (p2=1; p2<NBPAIRS+1; p2++)
      for (i=0; i<5; i++) {
        fprintf(outfp, "/* %2s.%c..%2s */\n",
                pnames[p1], bnames[i], pnames[p2]);
        for (j=0; j<5; j++)
          display_array(int21_dH[p1][p2][i][j],5,5, outfp);
      }
  }

  fprintf(outfp,"\n# %s\n", settype(INT22));
  { int p1, p2, i, j, k;
  for (p1=1; p1<NBPAIRS; p1++)
    for (p2=1; p2<NBPAIRS; p2++)
      for (i=1; i<5; i++)
        for (j=1; j<5; j++) {
          fprintf(outfp, "/* %2s.%c%c..%2s */\n",
                  pnames[p1], bnames[i], bnames[j], pnames[p2]);
          for (k=1; k<5; k++)
            display_array(int22_37[p1][p2][i][j][k]+1,4,5, outfp);
        }
  }

  fprintf(outfp,"\n# %s\n", settype(INT22_H));
  { int p1, p2, i, j, k;
  for (p1=1; p1<NBPAIRS; p1++)
    for (p2=1; p2<NBPAIRS; p2++)
      for (i=1; i<5; i++)
        for (j=1; j<5; j++) {
          fprintf(outfp, "/* %2s.%c%c..%2s */\n",
                  pnames[p1], bnames[i], bnames[j], pnames[p2]);
          for (k=1; k<5; k++)
            display_array(int22_dH[p1][p2][i][j][k]+1,4,5, outfp);
        }
  }

  fprintf(outfp,"\n# %s\n", settype(HP));
  display_array(hairpin37, 31, 10, outfp);

  fprintf(outfp,"\n# %s\n", settype(HP_H));
  display_array(hairpindH, 31, 10, outfp);

  fprintf(outfp,"\n# %s\n", settype(B));
  display_array(bulge37, 31, 10, outfp);

  fprintf(outfp,"\n# %s\n", settype(B_H));
  display_array(bulgedH, 31, 10, outfp);

  fprintf(outfp,"\n# %s\n", settype(IL));
  display_array(internal_loop37, 31, 10, outfp);

  fprintf(outfp,"\n# %s\n", settype(IL_H));
  display_array(internal_loopdH, 31, 10, outfp);

  fprintf(outfp,"\n# %s\n", settype(ML));
  fprintf(outfp,"/* F = cu*n_unpaired + cc + ci*loop_degree (+TermAU) */\n");
  fprintf(outfp,"/*\t    cu\t cu_dH\t    cc\t cc_dH\t    ci\t ci_dH  */\n");
  fprintf(outfp,"\t%6d\t%6d\t%6d\t%6d\t%6d\t%6d\n", ML_BASE37, ML_BASEdH, ML_closing37, ML_closingdH, ML_intern37, ML_interndH);

  fprintf(outfp,"\n# %s\n", settype(NIN));
  fprintf(outfp,"/* Ninio = MIN(max, m*|n1-n2| */\n"
              "/*\t    m\t  m_dH     max  */\n"
              "\t%6d\t%6d\t%6d\n", ninio37, niniodH, MAX_NINIO);

  fprintf(outfp,"\n# %s\n", settype(MISC));
  fprintf(outfp,"/* all parameters are pairs of 'energy enthalpy' */\n");
  fprintf(outfp,"/*    DuplexInit     TerminalAU      LXC */\n");
  fprintf(outfp,"   %6d %6d %6d  %6d %3.6f %6d\n", DuplexInit37, DuplexInitdH, TerminalAU37, TerminalAUdH, lxc37, 0);

  fprintf(outfp,"\n# %s\n", settype(HEX));
  for (c=0; c< strlen(Hexaloops)/9; c++)
    fprintf(outfp,"\t%.8s %6d %6d\n", Hexaloops+c*9, Hexaloop37[c], HexaloopdH[c]);

  fprintf(outfp,"\n# %s\n", settype(TL));
  for (c=0; c< strlen(Tetraloops)/7; c++)
    fprintf(outfp,"\t%.6s %6d %6d\n", Tetraloops+c*7, Tetraloop37[c], TetraloopdH[c]);

  fprintf(outfp,"\n# %s\n", settype(TRI));
  for (c=0; c< strlen(Triloops)/6; c++)
    fprintf(outfp,"\t%.5s %6d %6d\n", Triloops+c*6, Triloop37[c], TriloopdH[c]);

  fprintf(outfp,"\n# %s\n", settype(QUIT));
  fclose(outfp);
}
Beispiel #13
0
int cmd_list(int argc, const char **argv)
{
	const struct option options[] = {
		OPT_STRING('b', "bus", &param.bus, "bus-id", "filter by bus"),
		OPT_STRING('r', "region", &param.region, "region-id",
				"filter by region"),
		OPT_BOOLEAN('B', "buses", &list.buses, "include bus info"),
		OPT_BOOLEAN('D', "dimms", &list.dimms, "include dimm info"),
		OPT_BOOLEAN('R', "regions", &list.regions,
				"include region info"),
		OPT_BOOLEAN('N', "namespaces", &list.namespaces,
				"include namespace info (default)"),
		OPT_BOOLEAN('i', "idle", &list.idle, "include idle devices"),
		OPT_END(),
	};
	const char * const u[] = {
		"ndctl list [<options>]",
		NULL
	};
	struct json_object *jnamespaces = NULL;
	struct json_object *jregions = NULL;
	struct json_object *jdimms = NULL;
	struct json_object *jbuses = NULL;
	struct ndctl_ctx *ctx;
	struct ndctl_bus *bus;
	int i, rc;

        argc = parse_options(argc, argv, options, u, 0);
	for (i = 0; i < argc; i++)
		error("unknown parameter \"%s\"\n", argv[i]);
	if (argc)
		usage_with_options(u, options);

	rc = ndctl_new(&ctx);
	if (rc < 0)
		return rc;

	ndctl_bus_foreach(ctx, bus) {
		struct json_object *jbus = NULL;
		struct ndctl_region *region;
		struct ndctl_dimm *dimm;

		if (!util_bus_filter(bus, param.bus))
			continue;

		if (list.buses) {
			if (!jbuses) {
				jbuses = json_object_new_array();
				if (!jbuses) {
					fail("\n");
					continue;
				}
			}

			jbus = util_bus_to_json(bus);
			if (!jbus) {
				fail("\n");
				continue;
			}
			json_object_array_add(jbuses, jbus);
		}

		ndctl_dimm_foreach(bus, dimm) {
			struct json_object *jdimm;

			/* are we emitting dimms? */
			if (!list.dimms)
				break;

			if (!list.idle && !ndctl_dimm_is_enabled(dimm))
				continue;

			if (!jdimms) {
				jdimms = json_object_new_array();
				if (!jdimms) {
					fail("\n");
					continue;
				}

				if (jbus)
					json_object_object_add(jbus, "dimms", jdimms);
			}

			jdimm = util_dimm_to_json(dimm);
			if (!jdimm) {
				fail("\n");
				continue;
			}

			/*
			 * Without a bus we are collecting dimms anonymously
			 * across the platform.
			 */
			json_object_array_add(jdimms, jdimm);
		}

		ndctl_region_foreach(bus, region) {
			struct json_object *jregion;

			if (!util_region_filter(region, param.region))
				continue;

			if (!list.regions) {
				jnamespaces = list_namespaces(region, jbus,
						jnamespaces, true);
				continue;
			}

			if (!list.idle && !ndctl_region_is_enabled(region))
				continue;

			if (!jregions) {
				jregions = json_object_new_array();
				if (!jregions) {
					fail("\n");
					continue;
				}

				if (jbus)
					json_object_object_add(jbus, "regions",
							jregions);
			}

			jregion = region_to_json(region);
			if (!jregion) {
				fail("\n");
				continue;
			}

			/*
			 * Without a bus we are collecting regions anonymously
			 * across the platform.
			 */
			json_object_array_add(jregions, jregion);
		}

		if (jbuses) {
			jdimms = NULL;
			jregions = NULL;
			jnamespaces = NULL;
		}
	}

	if (jbuses)
		display_array(jbuses);
	else if ((!!jdimms + !!jregions + !!jnamespaces) > 1) {
		struct json_object *jplatform = json_object_new_object();

		if (!jplatform) {
			fail("\n");
			return -ENOMEM;
		}

		if (jdimms)
			json_object_object_add(jplatform, "dimms", jdimms);
		if (jregions)
			json_object_object_add(jplatform, "regions", jregions);
		if (jnamespaces)
			json_object_object_add(jplatform, "namespaces",
					jnamespaces);
		printf("%s\n", json_object_to_json_string_ext(jplatform,
					jflag));
		json_object_put(jplatform);
	} else if (jdimms)
		display_array(jdimms);
	else if (jregions)
		display_array(jregions);
	else if (jnamespaces)
		display_array(jnamespaces);

	if (did_fail)
		return -ENOMEM;
	return 0;
}
/***********************************************************************************************************************************************
*	FUNCTION NAME : main.c
*
*	DESCRIPTION : contains main function swhich call other functions for implementing the given problem statement
*
*	RETURN VALUE : SUCCESS
*
**************************************************************************************************************************************************/
int main(int argc, char *argv[])
{
	/*error handling for command line arguments*/
	if(NULL == argv[1])
	{
		printf("Please provide first input file name\n");
		exit(FAILURE);
	}

	if(NULL == argv[2])
	{
		printf("Please provide second input file name\n");
		exit(FAILURE);
	}

	if(NULL == argv[3])
	{
		printf("Please provide output file name\n");
		exit(FAILURE);
	}

	FILE *fp1; //file pointer for first input file
	FILE *fp2; //file pointer for second input file
	FILE *fp3; //file pointer for output file

	int index; //array index

	char string[MAX];//for storing strings
	memset(string,0,MAX*sizeof(char));//initializing input to null

	char *arr[MAX]; //array for storing names
	/*initializing array of pointers to null*/
	for (index=0; index<MAX-1; index++)
	{
		arr[index] = NULL;
	}

	file_open(&fp1, argv[1], "r");//opening first input file in read only mode
	file_open(&fp2, argv[2], "r");//opening second input file in read only mode
	file_open(&fp3,argv[3], "w");//opening output file in write only mode

	index = 0;
	/*reading from first input file & storing it in array*/
	while(1)
	{
		fgets(string, (MAX-1)*sizeof(char), fp1); //reading from the first input file
		/*error handling for end of file*/
		if(feof(fp1))
		{
			break;
		}
		insert_array(arr, string, index);
		++index;
	}

	/*reading from second input file and storing it in array*/
	while(1)
	{
		fgets(string, (MAX-1)*sizeof(char), fp2); //reading from the second input file
		/*error handling for end of file*/
		if(feof(fp2))
		{
			break;
		}
		insert_array(arr, string, index);
		++index;
	}

	printf("\n");
	printf("***************array before sorting*************************\n");
	display_array(arr, index);
	printf("\n\n");

	
	quicksort(arr, 0, index-1);//sorting the array
	printf("*******************array after sorting****************************\n");
	display_array(arr, index);
	printf("\n\n");


	insert_file(arr, index, &fp3);//read from the ds and store it in output file

	file_close(&fp1); //closing first input file
	file_close(&fp2); //closing second input file
	file_close(&fp3); //closing output file

	free_array(arr, index); //free the link list

	return SUCCESS;
}
Beispiel #15
0
void do_ban( char_data* ch, char* argument )
{
  account_data*   account;
  ban_data*           ban;
  pfile_data*       pfile  = NULL;
  int               flags;
  int                   i;
  bool              first  = TRUE;
  const char*        name;
  player_data*     victim;

  if( !get_flags( ch, argument, &flags, "srn", "Ban" ) )
    return;

  if( is_set( &flags, 2 ) ) {
    if( *argument == '\0' ) {
      if( badname_array == NULL ) {
        send( ch, "The badname array is empty.\n\r" );
        }
      else {
        display_array( ch, "Bad Name Array", &badname_array[0],
          &badname_array[1], max_badname );
        }
      return;
      }
    i = pntr_search( badname_array, max_badname, argument );
    if( is_set( &flags, 1 ) ) {
      if( i < 0 ) {
        send( ch, "The name '%s' wasn't in the badname array.\n\r",
          argument );
        }
      else {
        record_delete( sizeof( char* ), MEM_BADNAME );
        remove( badname_array, max_badname, i );
        send( ch, "Name removed from badname array.\n\r" );
        save_badname( );
        }
      }
    else {
      if( i > 0 ) {
        send( ch, "The name '%s' is already in the badname array.\n\r",
          argument );
        }
      else if( check_parse_name( ch->link, argument ) ) {
        i = -i-1;
        record_new( sizeof( char* ), MEM_BADNAME );
        name = alloc_string( argument, MEM_BADNAME );
        insert( badname_array, max_badname, name, i );
        send( ch, "The name '%s' is added to the badname array.\n\r",
          name );
        save_badname( );
        }
      }
    return;
    }

  if( is_set( &flags, 0 ) ) {
    if( *argument == '\0' ) {
      page_title( ch, "Banned Sites" );
      for( ban = ban_list; ban != NULL; ban = ban->next )
        page( ch, "%s\n\r", ban->name );
      return;
      }
    if( !is_set( &flags, 1 ) ) {
      for( ban = ban_list; ban != NULL; ban = ban->next ) {
        if( !strcasecmp( argument, ban->name ) ) {
          send( "That site is already banned!\n\r", ch );
          return;
          }
        }
      ban        = new ban_data;
      ban->name  = alloc_string( argument, MEM_BAN );
      save_banned( );
      send( ch, "Ok.\n\r" );
      }
    else {
      for( ban = ban_list; ban != NULL; ban = ban->next ) {
        if( !strcasecmp( argument, ban->name ) ) {
          delete ban;
          save_banned();
          send( ch, "Ok.\n\r" );
          return;
          }
        }
      send( ch, "Site is not banned.\n\r" );
      }
    return;
    }

  if( *argument == '\0' ) {
    page_title( ch, "Banned Accounts" );
    for( i = 0; i < max_account; i++ )
      if( account_list[i]->banned != -1 ) 
        display_account( ch, account_list[i], first );
    return;
    }

  if( ( account = account_arg( argument ) ) == NULL ) {
    if( ( pfile = player_arg( argument ) ) == NULL ) {
      send( ch, "No such account or player.\n\r" );
      return;
      }
    if( ( account = pfile->account ) == NULL ) {
      send( ch, "That player doesn't have an account which makes banning\
 it difficult.\n\r" );
      return;
      }
    }
Beispiel #16
0
PUBLIC void write_parameter_file(const char fname[]) {
  FILE *outfp;
  int c;
  char *pnames[] = {"NP", "CG", "GC", "GU", "UG", "AU", "UA", " @"};
  char bnames[] = "@ACGU";
  outfp = fopen(fname, "w");
  if (!outfp) {
    fprintf(stderr, "can't open file %s\n", fname);
    exit(1);
  }
  fprintf(outfp,"## RNAfold parameter file\n");
  
  fprintf(outfp,"\n# stack_energies\n");
  fprintf(outfp,"/*  CG    GC    GU    UG    AU    UA    @  */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(stack37[c]+1,NBPAIRS,NBPAIRS, outfp);
  
  fprintf(outfp,"\n# stack_enthalpies\n");
  fprintf(outfp,"/*  CG    GC    GU    UG    AU    UA    @  */\n");
  for (c=1; c<NBPAIRS+1; c++)
    display_array(enthalpies[c]+1,NBPAIRS,NBPAIRS, outfp);
  
  fprintf(outfp,"\n# mismatch_hairpin\n");
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++) 
      display_array(mismatchH37[k][i],5,5, outfp);
  }
  
  fprintf(outfp,"\n# mismatch_interior\n");
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++) 
      display_array(mismatchI37[k][i],5,5, outfp);
  }

  fprintf(outfp,"\n# mismatch_multi\n");
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++) 
      display_array(mismatchM37[k][i],5,5, outfp);
  }
  
  fprintf(outfp,"\n# mismatch_enthalpies\n");
  { int i,k;
  for (k=1; k<NBPAIRS+1; k++)
    for (i=0; i<5; i++) 
      display_array(mism_H[k][i],5,5, outfp);
  }
  fprintf(outfp,"\n# dangle5\n");
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=0; c<NBPAIRS+1; c++)
    display_array(dangle5_37[c], 5, 5, outfp);
  
  fprintf(outfp,"\n# dangle3\n");
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=0; c<NBPAIRS+1; c++)
    display_array(dangle3_37[c], 5, 5, outfp);
  
  fprintf(outfp,"\n# dangle5_enthalpies\n");
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=0; c<NBPAIRS+1; c++)
    display_array(dangle5_H[c], 5, 5, outfp);
  
  fprintf(outfp,"\n# dangle3_enthalpies\n");
  fprintf(outfp,"/*  @     A     C     G     U   */\n");
  for (c=0; c<NBPAIRS+1; c++)
    display_array(dangle3_H[c], 5, 5, outfp);


  /* don;t print "no pair" entries for interior loop arrays */
  fprintf(outfp,"\n# int11_energies\n");
  { int i,k,l;
  for (k=1; k<NBPAIRS+1; k++)
    for (l=1; l<NBPAIRS+1; l++) {
      fprintf(outfp, "/* %2s..%2s */\n", pnames[k], pnames[l]);
      for (i=0; i<5; i++)
	display_array(int11_37[k][l][i], 5, 5, outfp);
    }
  }

  fprintf(outfp,"\n# int11_enthalpies\n");
  { int i,k,l;
  for (k=1; k<NBPAIRS+1; k++)
    for (l=1; l<NBPAIRS+1; l++) {
      fprintf(outfp, "/* %2s..%2s */\n", pnames[k], pnames[l]);
      for (i=0; i<5; i++) 
	display_array(int11_H[k][l][i],5,5, outfp);
    }
  }

  fprintf(outfp,"\n# int21_energies\n");
  { int p1, p2, i, j;
  for (p1=1; p1<NBPAIRS+1; p1++) 
    for (p2=1; p2<NBPAIRS+1; p2++)
      for (i=0; i<5; i++) {
	fprintf(outfp, "/* %2s.%c..%2s */\n",
		pnames[p1], bnames[i], pnames[p2]);
	for (j=0; j<5; j++)
	  display_array(int21_37[p1][p2][i][j],5,5, outfp);
      }
  }

  fprintf(outfp,"\n# int21_enthalpies\n");
  { int p1, p2, i, j;
  for (p1=1; p1<NBPAIRS+1; p1++) 
    for (p2=1; p2<NBPAIRS+1; p2++)
      for (i=0; i<5; i++) {
	fprintf(outfp, "/* %2s.%c..%2s */\n",
		pnames[p1], bnames[i], pnames[p2]);
	for (j=0; j<5; j++)
	  display_array(int21_H[p1][p2][i][j],5,5, outfp);
      }
  }

  fprintf(outfp,"\n# int22_energies\n");
  { int p1, p2, i, j, k;
  for (p1=1; p1<NBPAIRS+1; p1++) 
    for (p2=1; p2<NBPAIRS+1; p2++)
      for (i=1; i<5; i++)
	for (j=1; j<5; j++) {
	  fprintf(outfp, "/* %2s.%c%c..%2s */\n",
		  pnames[p1], bnames[i], bnames[j], pnames[p2]);
	  for (k=1; k<5; k++) 
	    display_array(int22_37[p1][p2][i][j][k]+1,4,5, outfp);
	}
  }
  
  fprintf(outfp,"\n# int22_enthalpies\n");
  { int p1, p2, i, j, k;
  for (p1=1; p1<NBPAIRS+1; p1++) 
    for (p2=1; p2<NBPAIRS+1; p2++)
      for (i=1; i<5; i++)
	for (j=1; j<5; j++) {
	  fprintf(outfp, "/* %2s.%c%c..%2s */\n",
		  pnames[p1], bnames[i], bnames[j], pnames[p2]);
	  for (k=1; k<5; k++) 
	    display_array(int22_H[p1][p2][i][j][k]+1,4,5, outfp);
	}
  }
  
  fprintf(outfp,"\n# hairpin\n");
  display_array(hairpin37, 31, 10, outfp);
  
  fprintf(outfp,"\n# bulge\n");
  display_array(bulge37, 31, 10, outfp);
  
  fprintf(outfp,"\n# internal_loop\n");
  display_array(internal_loop37, 31, 10, outfp);
  
  fprintf(outfp,"\n# ML_params\n");
  fprintf(outfp,"/* F = cu*n_unpaired + cc + ci*loop_degree (+TermAU) */\n");
  fprintf(outfp,"/*\t    cu\t    cc\t    ci\t TerminalAU */\n");
  fprintf(outfp,"\t%6d\t%6d\t%6d\t%6d\n",
	  ML_BASE37, ML_closing37, ML_intern37, TerminalAU);
  
  fprintf(outfp,"\n# NINIO\n"
	  "/* Ninio = MIN(max, m*|n1-n2| */\n"
	  "/*       m   max              */\n"
	  "\t%3d %4d\n", F_ninio37[2], MAX_NINIO);

  fprintf(outfp,"\n# Tetraloops\n");
  for (c=0; c< strlen(Tetraloops)/7; c++)
    fprintf(outfp,"\t%.6s\t%4d\n", Tetraloops+c*7, TETRA_ENERGY37[c]);

  fprintf(outfp,"\n# Triloops\n");
  for (c=0; c< strlen(Triloops)/6; c++)
    fprintf(outfp,"\t%.5s\t%4d\n", Triloops+c*6, Triloop_E37[c]);

  fprintf(outfp, "\n#END\n");
  fclose(outfp);
}