int main(){
	srand(time(NULL));
	int array[3][3] = {{-1,-1,-1},{-1,-1,-1},{-1,-1,-1}};
	int randNum=rand()%9,x,y;
	for(x=0;x<3;x++){
		for(y=0;y<3;y++){
			while(is_in_list(array,randNum)){
				randNum=rand()%9;
			}
			array[x][y] = randNum;
            //printf("%d",randNum);
		}
	}
    printf("Print-Array\n");
    print_array(array);
    printf("From row and column\n");
    row_and_column(array);
    printf("Print column\n");
    print_column(array);
    printf("Print Row\n");
    print_row(array);
    printf("Get Address\n");
    get_row_column(array);
    printf("\n");
	return 0;
}
Exemple #2
0
	void print_t(ostream &os,const CQCircuit &circuit)
	{
		auto print_circuit_row{[&](ostream &os,const size_t i){
			print_IQBit_or_space(os,circuit[0][i]);
			for(size_t j{1};j!=circuit.size();++j)
			{
				print_row(os);
				print_IQBit_or_space(os,circuit[j][i]);
			}
			os<<endl;
		}};
		if(circuit.size())
		{
			print_circuit_row(os,0);
			for(size_t i{1};i!=circuit.gate_size();++i)
			{
				print_column(os);
				for(size_t j{1};j!=circuit.size();++j)
				{
					print_space(os);
					print_column(os);
				}
				os<<endl;
				print_circuit_row(os,i);
			}
		}
	}
Exemple #3
0
void print_matrix(double* mat,int n_rows,int row_length){
	int i;
	for(i=0;i<n_rows;i++){
		printf("Row %i: ",i);
		print_row(&(mat[row_length*i]),row_length);
	}
}
unsigned long long* pascal_triangle_line(unsigned int pascal_row){
    static unsigned int i, j;
    unsigned long long* result = NULL;
    result = (unsigned long long*)calloc(pascal_row, sizeof(unsigned long long));
    
    if ( NULL != result ) {    
        result[pascal_row-1] = 1; // First element on the right is always '1'
        for ( i = 2; i <= pascal_row; ++i ) {
            
            #ifdef DEBUG
            print_row(result, pascal_row);
            #endif
            
            for ( j = pascal_row-i; j < pascal_row-1; ++j ) {
                result[j] += result[j+1]; // Calculate the 'j'-th element
                
                #ifdef VERBOSE
                printf("(row: %d, element: %d) => %llu\n", i, j, result[j]);
                #endif
            }
        }
    }
        
    return (result);
}
int main(void)
{

  printf("Enter a number up to %d digits: ", MAX_DIGITS);
  fgets(input, sizeof(input), stdin);

  /* top row of all characters: only segment 0 is possible */
  print_row(NO_SEGMENT, 0, NO_SEGMENT);

  /* middle row of all characters: segments 5, 6, and 1 are possible */
  print_row(5, 6, 1);

  /* bottom row of all characters: segments 4, 3 and 2 are possible */
  print_row(4, 3, 2);

  return 0;
}
Exemple #6
0
void Sudoku::print() const
{
	for(int i = 0; i < 9; ++i){
		if(i == 3 || i == 6)
			std::cout << "------+-------+------" << std::endl;
		print_row(i);
	}
	std::cout << std::endl;
}
Exemple #7
0
template<typename T> static void print_default_pajeVariable_row(paje_event_t& event) {
  init_stream<T>(event);
  print_timestamp(event);
  stream << " " << static_cast<T>(event->data)->type->id
         << " " << static_cast<T>(event->data)->container->id
         << " " << static_cast<T>(event->data)->value;
         
  print_row();
}
Exemple #8
0
void pinta(){
    for (int v=0; v<NPILAS; v++){
	wclear(win[v]);
	box(win[v], 0 , 0);		
	for (int i=0; i<p[v]->summit; i++)
	    print_row(win[v], i, center(W, N), p[v]->data[i]);
    }
    getch();
}
Exemple #9
0
int main()
{
  std::vector<char> v(20, 'a'); // create std vector of 20 chars and initialize all with the value 'a'
  print_row(v); std::cout << std::endl;

  // create a 20 x 15 matrix:
  // make a std vector of 20 standard vectors, each initialized to be a standard vector of size 15
  std::vector< std::vector<int> > M(20, std::vector<int>(15)); // be sure to put spaces between >s
  print_mat(M);
}
Exemple #10
0
void SQL_Devices::print_results( )
{
    m_row = mysql_fetch_row( m_result );
    while ( m_row )
    {
        print_row( );
        m_row = mysql_fetch_row( m_result );
    }
    //printf("\n");
}
Exemple #11
0
void print(struct node * lList[], int n)
{
    int i;
    for(i = 0; i < n; i++)
    {
        printf("key: %d ",i);
        print_row(lList[i]);
        printf("\n");
    }
}
Exemple #12
0
	void print(ostream &os,const CQGate &gate)
	{
		print_IQBit_or_space(os,gate[0]);
		for(size_t i{1};i!=gate.gate_size();++i)
		{
			print_row(os);
			print_IQBit_or_space(os,gate[i]);
		}
		os<<endl;
	}
Exemple #13
0
void print_year()
{
	int row;
	char buf[32];
	sprintf(buf, "%d", year);
	space((width - strlen(buf)) / 2);
	printf("%s\n\n", buf);
	for (row = 0; row * cols < 12; row++)
		print_row(row);
}
Exemple #14
0
void print_sudoku() {
	int i;
	printf("#########################################################################################\n");
	for(i=0; i<9; i++) {
		if(i%3==0)
				printf(i==0?"":"=========================================================================================\n");
		else
			printf("---------+---------+---------#---------+---------+---------#---------+---------+---------\n");
		print_row(row[i]);
	}
}
Exemple #15
0
void print_raster_header(NIDS_raster *r, char *prefix) {
	int i;
	
	printf("%s.rast.x_start %i\n", prefix, r->x_start);
	printf("%s.rast.y_start %i\n", prefix, r->y_start);
	printf("%s.rast.num_rows %i\n", prefix, r->num_rows);
	
	for (i = 0 ; i < r->num_rows ; i++)
		print_row(r->rows + i, prefix, i);

}
Exemple #16
0
void print_mat(const std::vector< std::vector<Cl> >& mat)
{
  std::cout << "[";
  for(auto i = mat.begin(); i != mat.end(); ++i)
  {
    if(i != mat.begin()) std::cout << " ";
    print_row(*i);
    if(i != mat.end()-1) std::cout << std::endl;
  }
  std::cout << "]" << std::endl;
}
Exemple #17
0
 void print(std::ostream& os, const grid<Iter1, Iter2>& grid, const Values&... values) {
     ads::util::stream_state_saver guard(os);
     prepare_stream(os);
     const auto& xs = get_range<0>(grid);
     const auto& ys = get_range<1>(grid);
     for (std::size_t i = 0; i < xs.size(); ++ i) {
         for (std::size_t j = 0; j < ys.size(); ++ j) {
             print_row(os, xs[i], ys[j], values(i, j)...);
         }
     }
 }
void print_matrix(FILE *f, arith_vartable_t *vtbl, matrix_t *matrix) {
  uint32_t i, n;

  n = matrix->nrows;
  for (i=0; i<n; i++) {
    fprintf(f, "  row[%"PRIu32"]:   ", i);
    print_space(f, i, n);
    print_row(f, vtbl, matrix->row[i]);
    fputc('\n', f);
  }
  fputc('\n', f);
}
Exemple #19
0
void pascal_row(int row[], int rows) {
  int curr_row, i, prev = 1, cell;

  for (curr_row = 0; curr_row < rows; curr_row++) {
    for (i = 0; i <= curr_row; i++) {
      cell = prev + row[i];
      prev = row[i];
      row[i] = cell;
    }
    print_row(row);
  }
}
Exemple #20
0
static void
print_header(void)
{
	int i, j;

	i = printf("Test case");
	for (j = 60 - i; j > 0; j--)
		printf(" ");
	printf("Result\n");

	print_row('-');
}
Exemple #21
0
void print_entry(struct dirent *entry, struct stat s)
{
  #define value_len 20
  static const char *time_fmt = "%F %T";
  static const char thick = '=';
  static const char thin = '-';
  static const int width = 72;
  static const int col = 12;

  print_border(thick, width, 0);
  print_row(entry->d_name, NULL, width, 0);
  print_border(thick, width, col);
  char size[value_len];
  format_bytes(size, value_len, s.st_size);
  print_row("Size", size, width, col);
  print_border(thin, width, col);
  char *type;
  switch (entry->d_type) {
    case DT_REG:
      type = "Regular file";
      break;
    case DT_LNK:
      type = "Symbolic link";
      break;
    default:
      type = "Unrecognized";
      break;
  }
  print_row("Type", type, width, col);
  print_border(thin, width, col);
  char mtime[value_len];
  strftime(mtime, value_len, time_fmt, localtime(&s.st_mtimespec.tv_sec));
  print_row("Modified", mtime, width, col);
  print_border(thin, width, col);
  char atime[value_len];
  strftime(atime, value_len, time_fmt, localtime(&s.st_atimespec.tv_sec));
  print_row("Accessed", atime, width, col);
  print_border(thick, width, 0);
}
Exemple #22
0
int main()
{
	int row;
	int scale;

	/*Input*/
	printf("Enter scale quantifier: "); scanf("%d", &scale);

	/*Output*/
	for (row = 1; row <= BOARD_ROWS; row++)
		print_row(row, scale);

	return 0;
}
template <typename T, typename X> void core_solver_pretty_printer<T, X>::print() {
    for (unsigned i = 0; i < nrows(); i++) {
        print_row(i);
    }
    print_bottom_line();
    print_cost();
    print_x();
    print_basis_heading();
    print_lows();
    print_upps();
    print_exact_norms();
    print_approx_norms();
    m_out << std::endl;
}
Exemple #24
0
void print_board(Board board)
{
	for (int x = 0; x < board.dimx; x++)
		printf("    %i",x);
	printf("\n");
	
	print_roof(board);
	
	for (int x = 0; x < board.dimx; x++)
	{
		print_row(board, x);
		print_roof(board);
	}
}
Exemple #25
0
void print_puzzle() {
	int r; // Incrementation variable

	print_dashes();

	for(r = 1; r < 10; r++){
		
		print_row(r);

		if (( r % 3 ) == 0 ){
			print_dashes();
		}	

	}
}
Exemple #26
0
int process_file(char *filename, lnf_filter_t *filterp) {

    lnf_file_t *filep;
    lnf_rec_t *recp;
//	lnf_brec1_t brec;
    int i = 0;
    int tid;
    int match;

    tid = (int)pthread_self();


    if (lnf_open(&filep, filename, LNF_READ, NULL) != LNF_OK) {
        fprintf(stderr, "[#%x] Can not open file %s\n", tid, filename);
        return 0;
    }

    lnf_rec_init(&recp);

    while (lnf_read(filep, recp) != LNF_EOF) {

        i++;

        match = 1;

        if ( filterp != NULL ) {
            match = lnf_filter_match(filterp, recp);
        }

        /* add to memory heap */
        if ( match ) {
            if (memp != NULL) {
                lnf_mem_write(memp, recp);
            } else {
                print_row(recp);
                outputflows++;
            }
        }

    }

    lnf_close(filep);

//	printf("[#%x] Total input records in file %s : %d\n", tid, filename, i);

    return i;
}
Exemple #27
0
void						loop(t_ncurse *ncurse)
{
	int						y;

	while (42)
	{
		y = 0;
		while (y < Y)
		{
			print_line(ncurse, y);
			y++;
		}
		print_row(y * 2);
		refresh();
		sleep(1);
	}
}
int main(int argc, char** argv)
{
    unsigned int input;
    unsigned long long* result = NULL;
       
    // Check the Input
	if ( argc == 2 ) input = atoi(argv[1]); else return (EXIT_FAILURE);
    
    // Calculate the required line
    result = pascal_triangle_line(input);
    
    // Print result
    if ( NULL != result ) { 
        printf("RESULT ROW:\n");
        print_row(result, input);
        return (EXIT_SUCCESS);
    }
    return (EXIT_FAILURE);
}
int main(int argc, char *argv[]){
	int h, w, i, len;

	if (argc < 2) {
		return (1);
	}
	if (argv[1] <= 0) {
		return (1);
	}
	len = string_to_integer(argv[1]);
	h = len;
	w = len;

	if (len == 1){
		print_char('X');
		print_char('\n');
	} else {
		for (i=0; i<=len; i++){
			print_row(i, len);
		}
	}
}
Exemple #30
0
static void
print_summary(prop_array_t runlist)
{
	float total_run;
	float total_tests;

	total_tests = 0.0 + prop_array_count(runlist);
	total_run = 0.0 + total_tests - count_by_result[RESULT_BUILDFAIL] -
	    count_by_result[RESULT_PREFAIL] - count_by_result[RESULT_NOTRUN] -
	    count_by_result[RESULT_UNKNOWN];

	printf("\n\n");
	print_row('=');
	printf("Summary:\n\n");


	printf("Tests not built:\t%d\n", count_by_result[RESULT_BUILDFAIL]);

	printf("Tests not run:\t\t%.0f\n", total_tests - total_run);

	printf("Tests pre-failed:\t%d\n", count_by_result[RESULT_PREFAIL]);

	printf("Tests post-failed:\t%d\n", count_by_result[RESULT_POSTFAIL]);

	printf("Tests passed:\t\t%d\n", count_by_result[RESULT_PASS]);

	printf("Tests failed:\t\t%d\n", count_by_result[RESULT_FAIL]);

	printf("Tests crashed:\t\t%d\n", count_by_result[RESULT_SIGNALLED]);

	printf("Tests timed out:\t%d\n", count_by_result[RESULT_TIMEOUT]);


	printf("------\n");

	printf("Run rate:\t\t%.2f\n", total_run/total_tests);
	printf("Pass rate:\t\t%.2f\n", count_by_result[RESULT_PASS]/total_run);
}