int fill_in(int **map, int position, int nb) { int i; int j; if (position == 81) { ft_print_map(map); return (1); } i = position / 9; j = position % 9; if (map[i][j] != 0) return (fill_in(map, position + 1, nb)); nb = 1; while (nb <= 9) { if (c_row(nb, map, i) && c_col(nb, map, j) && c_sqr(nb, map, i, j)) { map[i][j] = nb; if (fill_in(map, position + 1, nb)) return (1); } nb++; } map[i][j] = 0; return (0); }
void fill_in_squarewave(st_signal * signal, int bytes) { signal->no_samples = (int) signal->signalspec->params.psquare.period_ms; signal->perioddata = calloc(signal->no_samples, bytes); assert(signal->perioddata); int i; for (i=0; i < signal->no_samples ; i++) { if (i < signal->no_samples / 2) fill_in(bytes, signal->signalspec->params.psquare.low, signal->perioddata, i); else fill_in(bytes, signal->signalspec->params.psquare.high, signal->perioddata, i); } }
void fill_in_constant(st_signal * signal, int bytes) { signal->no_samples = 1; signal->perioddata = calloc(1, bytes); assert(signal->perioddata); fill_in(bytes, signal->signalspec->params.pconst.value, signal->perioddata, 0); }
int block_type_flower(BlockType * self) { fill_in(); for (int i = 1; i < 8; i += 1) { if (self == block_types_flowers [i]) { return i; } } #line 76 return 0; }
int main(int ac, char **av) { int fill_answer; if (ac != 10) { ft_putstr("Erreur\n"); return (0); } fill_answer = fill_in((creat_int_map(av)), 1, 0); if (fill_answer == 0) ft_putstr("Erreur\n"); return (0); }
int impute_parent(Family *f, int m, int use_affected) { int locus, ia1, ia2, miss_f, miss_m; Offspring *child; for (ia2=1, ia1=locus=0; locus<m; locus++, ia1+=2, ia2+=2) { miss_f = !f->father[ia1] || !f->father[ia2]; miss_m = !f->mother[ia1] || !f->mother[ia2]; /* If one parent only missing, we may be able to guess the rest */ if ((miss_f && !miss_m)||(miss_m && !miss_f)) { for(child = f->children; child; child=child->next) { if (use_affected || child->affected!=2) { if (miss_f) { if (fill_in(child->markers+ia1, f->father+ia1, f->mother+ia1)) return 1; } else { if (fill_in(child->markers+ia1, f->mother+ia1, f->father+ia1)) return 1; } } } } } return 0; }
void server_request(struct server *sv, int connfd) { if (sv->nr_threads == 0) { /* no worker threads */ do_server_request(sv, connfd); } else { fill_in(sv, connfd); //pthread_cond_signal(&BLOCK); /* Save the relevant info in a buffer and have one of the * worker threads do the work. */ } }
void fill_in_sinewave(st_signal * signal, int bytes) { signal->no_samples = (int) signal->signalspec->params.psine.period_ms; signal->perioddata = calloc(signal->no_samples, bytes); assert(signal->perioddata); int i; double angle, value; for (i=0; i < signal->no_samples ; i++) { angle = (M_PI * 2.0 * i) / signal->no_samples; value = signal->signalspec->params.psine.low + (signal->signalspec->params.psine.high - signal->signalspec->params.psine.low ) * sin(angle); fill_in(bytes, value, signal->perioddata, i); } }
int main(int argc, char *argv[]){ // El usuario debe introducir dos argumentos, el nombre del programa y el exponente. if(argc!=2) error(argv[0]); int list[N], exponent = atoi(argv[1]); //se convierte a entero. fill_in(list); //se rellena la matriz. power(list, exponent); // Se expone el numero al exponente que indica el usuario. for(int contador=0; contador<N; contador++) printf("%i ", list[contador]); printf("\n"); return EXIT_SUCCESS; }
void fill_in_ramp(st_signal * signal, int bytes) { signal->no_samples = (int) signal->signalspec->params.pramp.period_ms; signal->perioddata = calloc(signal->no_samples, bytes); assert(signal->perioddata); int i; int no_x; // integer count where the samples are "high" int no_samples = signal->no_samples; double value; double low = signal->signalspec->params.pramp.low; double high = signal->signalspec->params.pramp.high; no_x = (int) ( signal->signalspec->params.pramp.symmetry / 100.0 * no_samples); for (i=0; i < signal->no_samples ; i++) { if (i < no_x) value = low + ((high - low) * i )/ no_x; else value = high - (high - low) * ( i - no_x) / (no_samples - no_x); fill_in(bytes, value, signal->perioddata, i); } }
int main( int argc, char * argv[ ] ) { fl_initialize( &argc, argv, "FormDemo", 0, 0 ); create_form_form( ); fill_in( barchart ); fill_in( horbarchart ); fill_in( linechart ); fl_set_object_helper( linechart, "A LineChart" ); fill_in( filledchart ); fill_in( spikechart ); fill_in( piechart ); fill_in( specialpiechart ); fl_show_form( form, FL_PLACE_CENTER, FL_TRANSIENT, "Charts" ); fl_do_forms( ); fl_finish( ); return 0; }
/* * Expand a token sequence * If skip_defined is true then the defined() keyword is not processed * The caller is used for registering invocations from one macro to another * This is an implementation of Dave Prosser's algorithm, listed in * X3J11/86-196 */ PtokenSequence macro_expand(PtokenSequence ts, bool get_more, bool skip_defined, const Macro *caller) { PtokenSequence r; // Return value if (DP()) cout << "Expanding: " << ts << endl; while (!ts.empty()) { const Ptoken head(ts.front()); ts.pop_front(); if (head.get_code() != IDENTIFIER) { // Only attempt to expand identifiers (not e.g. string literals) r.push_back(head); continue; } if (skip_defined && head.get_code() == IDENTIFIER && head.get_val() == "defined") { // Skip the arguments of the defined operator, if needed PtokenSequence da(gather_defined_operator(ts)); r.push_back(head); r.splice(r.end(), da); continue; } const string name = head.get_val(); mapMacro::const_iterator mi(Pdtoken::macros_find(name)); if (!Pdtoken::macro_is_defined(mi)) { // Nothing to do if the identifier is not a macro r.push_back(head); continue; } const Macro& m = mi->second; if (head.hideset_contains(m.get_name_token())) { // Skip the head token if it is in the hideset if (DP()) cout << "Skipping (head is in HS)" << endl; r.push_back(head); continue; } if (DP()) cout << "replacing for " << name << " tokens " << ts << endl; PtokenSequence removed_spaces; if (!m.is_function) { // Object-like macro Token::unify((*mi).second.name_token, head); HideSet hs(head.get_hideset()); hs.insert(m.get_name_token()); PtokenSequence s(subst(m, m.value, mapArgval(), hs, skip_defined, caller)); ts.splice(ts.begin(), s); caller = &m; } else if (fill_in(ts, get_more, removed_spaces) && ts.front().get_code() == '(') { // Application of a function-like macro Token::unify((*mi).second.name_token, head); mapArgval args; // Map from formal name to value if (DP()) cout << "Expanding " << m << " inside " << caller << "\n"; if (caller && caller->is_function) // Macro to macro call Call::register_call(caller->get_mcall(), m.get_mcall()); else // Function to macro call Call::register_call(m.get_mcall()); ts.pop_front(); Ptoken close; if (!gather_args(name, ts, m.formal_args, args, get_more, m.is_vararg, close)) continue; // Attempt to bail-out on error HideSet hs; set_intersection(head.get_hideset().begin(), head.get_hideset().end(), close.get_hideset().begin(), close.get_hideset().end(), inserter(hs, hs.begin())); hs.insert(m.get_name_token()); PtokenSequence s(subst(m, m.value, args, hs, skip_defined, caller)); ts.splice(ts.begin(), s); caller = &m; } else { // Function-like macro name lacking a ( if (DP()) cout << "splicing: [" << removed_spaces << ']' << endl; ts.splice(ts.begin(), removed_spaces); r.push_back(head); } } return (r); }
BlockType* block_flower(int i) { fill_in(); return block_types_flowers [i]; }
int main(int argc, char **argv) { struct umem_mgr *umem_mgr = umem_alloc_mgr_alloc(); assert(umem_mgr != NULL); struct ubuf_mgr *mgr; struct ubuf *ubuf1, *ubuf2; const char *channel; size_t size; uint8_t sample_size; uint8_t *w; const uint8_t *r; /* packed s16 stereo */ mgr = ubuf_sound_mem_mgr_alloc(UBUF_POOL_DEPTH, UBUF_POOL_DEPTH, umem_mgr, 4, 32); assert(mgr != NULL); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "lr")); ubuf1 = ubuf_sound_alloc(mgr, 32); assert(ubuf1 != NULL); ubase_assert(ubuf_sound_size(ubuf1, &size, &sample_size)); assert(size == 32); assert(sample_size == 4); channel = NULL; unsigned int nb_planes = 0; while (ubase_check(ubuf_sound_plane_iterate(ubuf1, &channel)) && channel != NULL) { nb_planes++; assert(!strcmp(channel, "lr")); } assert(nb_planes == 1); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "lr", 0, -1, &r)); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "lr", 0, -1)); fill_in(ubuf1); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "lr", 2, 1, &r)); assert(*r == 'l' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "lr", 2, 1)); ubuf2 = ubuf_dup(ubuf1); assert(ubuf2 != NULL); ubase_nassert(ubuf_sound_plane_write_uint8_t(ubuf1, "lr", 0, -1, &w)); ubuf_free(ubuf2); ubase_nassert(ubuf_sound_resize(ubuf1, 0, 33)); ubase_assert(ubuf_sound_resize(ubuf1, 2, -1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "lr", 0, -1, &r)); assert(r[0] == 'l' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "lr", 0, -1)); ubase_assert(ubuf_sound_resize(ubuf1, 0, 29)); ubuf_free(ubuf1); ubuf_mgr_release(mgr); /* planar float 5.1 */ mgr = ubuf_sound_mem_mgr_alloc(UBUF_POOL_DEPTH, UBUF_POOL_DEPTH, umem_mgr, sizeof(float), 32); assert(mgr != NULL); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "l")); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "r")); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "c")); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "L")); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "R")); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "S")); ubuf1 = ubuf_sound_alloc(mgr, 32); assert(ubuf1 != NULL); ubase_assert(ubuf_sound_size(ubuf1, &size, &sample_size)); assert(size == 32); assert(sample_size == sizeof(float)); channel = NULL; nb_planes = 0; while (ubase_check(ubuf_sound_plane_iterate(ubuf1, &channel)) && channel != NULL) nb_planes++; assert(nb_planes == 6); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "l", 0, -1, &r)); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "l", 0, -1)); fill_in(ubuf1); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "l", 2, 1, &r)); assert(*r == 'l' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "l", 2, 1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "r", 2, 1, &r)); assert(*r == 'r' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "r", 2, 1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "c", 2, 1, &r)); assert(*r == 'c' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "c", 2, 1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "L", 2, 1, &r)); assert(*r == 'L' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "L", 2, 1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "R", 2, 1, &r)); assert(*r == 'R' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "R", 2, 1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "S", 2, 1, &r)); assert(*r == 'S' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "S", 2, 1)); ubuf2 = ubuf_dup(ubuf1); assert(ubuf2 != NULL); ubase_nassert(ubuf_sound_plane_write_uint8_t(ubuf1, "l", 0, -1, &w)); ubuf_free(ubuf2); ubase_nassert(ubuf_sound_resize(ubuf1, 0, 33)); ubase_assert(ubuf_sound_resize(ubuf1, 2, -1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "l", 0, -1, &r)); assert(r[0] == 'l' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "l", 0, -1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "r", 0, -1, &r)); assert(r[0] == 'r' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "r", 0, -1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "c", 0, -1, &r)); assert(r[0] == 'c' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "c", 0, -1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "L", 0, -1, &r)); assert(r[0] == 'L' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "L", 0, -1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "R", 0, -1, &r)); assert(r[0] == 'R' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "R", 0, -1)); ubase_assert(ubuf_sound_plane_read_uint8_t(ubuf1, "S", 0, -1, &r)); assert(r[0] == 'S' + 8); ubase_assert(ubuf_sound_plane_unmap(ubuf1, "S", 0, -1)); ubase_assert(ubuf_sound_resize(ubuf1, 0, 29)); ubuf_free(ubuf1); ubuf_mgr_release(mgr); /* sound -> block transformation */ mgr = ubuf_sound_mem_mgr_alloc(UBUF_POOL_DEPTH, UBUF_POOL_DEPTH, umem_mgr, 4, 32); assert(mgr != NULL); ubase_assert(ubuf_sound_mem_mgr_add_plane(mgr, "lr")); ubuf1 = ubuf_sound_alloc(mgr, 32); assert(ubuf1 != NULL); fill_in(ubuf1); struct ubuf_mgr *block_mgr = ubuf_block_mem_mgr_alloc(UBUF_POOL_DEPTH, UBUF_POOL_DEPTH, umem_mgr, 0, 0, 0, 0); struct ubuf *ubuf_block = ubuf_block_mem_alloc_from_sound(block_mgr, ubuf1, "lr"); assert(ubuf_block != NULL); ubase_assert(ubuf_block_size(ubuf_block, &size)); assert(size == 32 * 4); int size2 = -1; ubase_assert(ubuf_block_read(ubuf_block, 0, &size2, &r)); assert(size2 == 32 * 4); assert(r[0] == 'l'); ubuf_free(ubuf_block); ubuf_mgr_release(block_mgr); ubuf_free(ubuf1); ubuf_mgr_release(mgr); umem_mgr_release(umem_mgr); return 0; }