Esempio n. 1
0
void
print_xlog_bad_data(xfs_daddr_t blkno)
{
	print_stars();
	printf(_("* ERROR: data block=%-21lld                             *\n"),
		(long long)blkno);
	print_stars();
	if (print_exit)
	    xlog_exit("Bad data in log");
}	/* print_xlog_bad_data */
Esempio n. 2
0
static void
print_xlog_bad_zeroed(xfs_daddr_t blkno)
{
	print_stars();
	printf(_("* ERROR: found data after zeroed blocks block=%-21lld  *\n"),
		(long long)blkno);
	print_stars();
	if (print_exit)
	    xlog_exit("Bad log - data after zeroed blocks");
}	/* print_xlog_bad_zeroed */
Esempio n. 3
0
static void
print_xlog_bad_header(xfs_daddr_t blkno, char *buf)
{
	print_stars();
	printf(_("* ERROR: header cycle=%-11d block=%-21lld        *\n"),
		xlog_get_cycle(buf), (long long)blkno);
	print_stars();
	if (print_exit)
	    xlog_exit("Bad log record header");
}	/* print_xlog_bad_header */
Esempio n. 4
0
static void
print_xlog_bad_reqd_hdrs(xfs_daddr_t blkno, int num_reqd, int num_hdrs)
{
	print_stars();
	printf(_("* ERROR: for header block=%lld\n"
	       "*        not enough hdrs for data length, "
		"required num = %d, hdr num = %d\n"),
		(long long)blkno, num_reqd, num_hdrs);
	print_stars();
	if (print_exit)
	    xlog_exit(_("Not enough headers for data length."));
}	/* print_xlog_bad_reqd_hdrs */
int main(int argc, char **argv)
{
  struct timespec T;
  unsigned N = 42;
  unsigned histogram[NUM_HIST_BOXES] = {0};
  star_array_t stars = star_array_initialize(N);
  star_array_t sorted_stars = star_array_initialize(N);
  sym_matrix_t matrix = sym_matrix_intitialize(N);
  if(!matrix){
    report(FAIL, "Failed to allocate matrix: %s (%d)", strerror(errno), errno);
    return -1;
  }
  float_t *tally =  malloc(sizeof(float_t)*triag_nr(N-2));
  if(!tally){
    report(FAIL, "Failed to allocate tally: %s (%d)", strerror(errno), errno);
    return -1;
  }
  create_random_array(stars, N);
  report(INFO, "starting sort");
  optim_sort(stars, sorted_stars, N);
  report(INFO, "sorted");
  print_stars(sorted_stars, N);
  fill_matrix(sorted_stars, matrix, N);
  //print_matrix(matrix, N);
  create_tally_matrix(matrix, tally, N);
  //print_tally_matrix(tally, N-2);
  hist_param_t histparams = generate_histogram(tally, histogram, N-2, NUM_HIST_BOXES);
  display_histogram(histogram, histparams);
  star_array_free(stars);
  star_array_free(sorted_stars);
  sym_matrix_free(matrix);
  free(tally);
}
Esempio n. 6
0
SNDFMT* gen_pwm_buffer(float duty_cycle){
  SNDFMT* buffer = malloc(sizeof(SNDFMT)*WAVEFORM_LENGTH);
  int i;
  //float data;
  for(i=0;i<WAVEFORM_LENGTH * duty_cycle;i++){
	//    data = 255.0 * 0.0;
    buffer[i] = (SNDFMT) 0;
	//    printf("pwm : %f buffer[%i] is : %i\n", data, i, buffer[i]);
	print_stars(0);	
	printf("\n");
  }
  for(;i<WAVEFORM_LENGTH;i++){
	//    data = 255.0 * 1.0 ;
    buffer[i] = (SNDFMT) 255;
	//    printf("pwm: %f buffer[%i] is : %i\n", data, i, buffer[i]);
	print_stars(10);
	printf("\n");
  }
  return buffer;
}
/* print a triangle of height h */
void print_triangles(int h)
{
 int row, stars, spaces;

 for (row = 1; row <= h; row++)
   {
     spaces = h - row;
     stars = 2 * row - 1;
     print_spaces(spaces);
     print_stars(stars);
     printf("%c", '\n');
   }
 }
Esempio n. 8
0
int main() {
    int next, total_to_10, total_to_20, total_to_30, total_over_30;

    scanf("%d", &next);

    total_to_10 = 0;
    total_to_20 = 0;
    total_to_30 = 0;
    total_over_30 = 0;

    while (next != -1) {
        if (next <= 10)
            total_to_10 += 1;
        else if (next <= 20)
            total_to_20 += 1;
        else if (next <= 30)
            total_to_30 += 1;
        else
            total_over_30 += 1;

        scanf("%d", &next);
    }

    printf("The total under 11 is: %d\n", total_to_10);
    printf("The total under 21 is: %d\n", total_to_20);
    printf("The total under 31 is: %d\n", total_to_30);
    printf("The total over 30 is:  %d\n", total_over_30);

    printf("the total under 11: ");
    print_stars(total_to_10);
    printf("the total under 21: ");
    print_stars(total_to_20);
    printf("the total under 31: ");
    print_stars(total_to_30);
    printf("the total over 30:  ");
    print_stars(total_over_30);

    return EXIT_SUCCESS;
}
Esempio n. 9
0
int main() {
	int nchar ; /* next character read */
	int curr_count = 0; /* count for current letter */
	int max_count = 0; /* highest frequency of letter */
	int i, j, k; /* counters */


	/* assign getchar() to nchar, loop until end of file */
	while((nchar = getchar()) != EOF) {
		if(isalpha(nchar)) {
			/* convert to uppercase, increment count in array */
			nchar = toupper(nchar);
			count[nchar - A_VALUE] += 1;
		}
	}

	/* getting the highest count from all letters */
	for(i = 0; i < NLETTERS; i++) {
		if(count[i] > max_count)
			max_count = count[i];
	}

	/* scaling the count */
	for(j = 0; j < NLETTERS; j++) {
		curr_count = count[j];
		if(curr_count > 0)
			count[j] = (MAXSTARS * curr_count) / max_count;
	}

	/* print the stars for the histogram */
	for(k = 0; k < NLETTERS; k++) {
		/* print out the letter value */
		printf("%c ", (A_VALUE + k));
		/* print out the asterisks */
		print_stars( count[k] );
		printf("\n");
	}
	return 0 ;
}