main(int argc, char ** argv) { check_help(); pgetopt(argc, argv, "", "$Revision: 1.5 $", _SRC_); printf("%s\n", gethist(argc, argv)); }
main(int argc, char ** argv) { check_help(); extern char *poptarg; extern char *poparr[]; int c; const char *param_string = ""; while ((c = pgetopt(argc, argv, param_string, "$Revision: 1.5 $", _SRC_)) != -1) switch(c) { case '?': params_to_usage(cerr, argv[0], param_string); get_help(); exit(1); } dyn *b; real prev_time = -VERY_LARGE_NUMBER; cerr.precision(HIGH_PRECISION); while (b = get_dyn()) { real time = b->get_system_time(); if (prev_time > -VERY_LARGE_NUMBER) { real dt = time - prev_time; PRC(time); PRL(dt); } else PRL(time); prev_time = time; rmtree(b); } }
int main(int argc, char *argv[]) { struct students_info students_list[number_of_students]; if (argc > 1){ if (!strcmp(argv[1], "-h")){ check_help(); } } enter_inform_students(students_list); if (argc > 1){ if (!strcmp(argv[1], "-m")){ puts_minsk(students_list); } if (!strcmp(argv[1], "-c")){ puts_regional_city(students_list); } if (!strcmp(argv[1], "-t")){ puts_not_regional_city(students_list); } if (!strcmp(argv[1], "-v")){ puts_village(students_list); } if (!strcmp(argv[1], "-l")){ puts_all_stud(students_list); } } getchar(); return 0; }
int main(int argc, char ** argv) { int n = 1; real m = 1.0; check_help(); extern char *poptarg; int c; const char *param_string = "m:n:"; while ((c = pgetopt(argc, argv, param_string, "$Revision: 1.9 $", _SRC_)) != -1) switch(c) { case 'm': m = atof(poptarg); break; case 'n': n = atoi(poptarg); break; case '?': params_to_usage(cerr, argv[0], param_string); get_help(); exit(1); } if (m <= 0) err_exit("mknodes: M > 0 required!"); if (n <= 0) err_exit("mknodes: N > 0 required!"); node * root = mknode_mass(n, m); root->log_history(argc, argv); put_node(root); rmtree(root); return 0; }
int main(int argc, char **argv) { int array_size, arg1; student_t *stud; check_help(argc, argv); if(!strcmp(argv[1], "1") || !strcmp(argv[1], "2")) { stud = (student_t*)malloc(max_base*sizeof(student_t)); if(!strcmp(argv[1], "1")) { arg1 = 0; } else { arg1 = 1; if(!(!strcmp(argv[2], "1") || !strcmp(argv[2], "2") || !strcmp(argv[2], "3"))) { puts("Input command-line data is wrong. Re-run program according to next rules:\n \''-h\'' (means help), \''1\'' or \''2\'' - for first argument\n \''1\'', \''2\'' or \''3\'' - for second argument\n"); return 0; } } array_size = init_array(arg1, argv, stud); stud_output(array_size, stud, argv); free(stud); } else puts("Input command-line data is wrong. Re-run program according to next rules:\n \''-h\'' (means help), \''1\'' or \''2\'' - for first argument\n \''1\'', \''2\'' or \''3\'' - for second argument\n"); return 0; }
int isl_args_parse(struct isl_args *args, int argc, char **argv, void *opt, unsigned flags) { int a = -1; int skip = 0; int i; int n; struct isl_prefixes prefixes = { 0 }; n = n_arg(args->args); for (i = 1; i < argc; ++i) { if ((strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0) && any_version(args->args)) print_version_and_exit(args->args); } while (argc > 1 + skip) { int parsed; if (argv[1 + skip][0] != '-') { a = next_arg(args->args, a); if (a >= 0) { char **p; p = (char **)(((char *)opt)+args->args[a].offset); free(*p); *p = strdup(argv[1 + skip]); argc = drop_argument(argc, argv, 1 + skip, 1); --n; } else if (ISL_FL_ISSET(flags, ISL_ARG_ALL)) { fprintf(stderr, "%s: extra argument: %s\n", prog_name(argv[0]), argv[1 + skip]); exit(-1); } else ++skip; continue; } check_help(args, argv[1 + skip], argv[0], opt, flags); parsed = parse_option(args->args, &argv[1 + skip], &prefixes, opt); if (parsed) argc = drop_argument(argc, argv, 1 + skip, parsed); else if (ISL_FL_ISSET(flags, ISL_ARG_ALL)) { fprintf(stderr, "%s: unrecognized option: %s\n", prog_name(argv[0]), argv[1 + skip]); exit(-1); } else ++skip; } if (n > 0) { fprintf(stderr, "%s: expecting %d more argument(s)\n", prog_name(argv[0]), n); exit(-1); } return argc; }
int main (int argc, char **argv) { int array_size; struct kindergarden *children; children = (struct kindergarden*)malloc(max_base*sizeof(struct kindergarden)); check_help(argc, argv); array_size = init_array(children); sort_array(children, array_size); search_illness(children, array_size, argv); free(children); return 0; }
/*----------------------------------------------------------------------------- * main -- driver to create directly a single node *----------------------------------------------------------------------------- */ main(int argc, char ** argv) { bool c_flag = FALSE; bool i_flag = FALSE; real m = 1; // default mass: unity char *comment; check_help(); extern char *poptarg; int c; const char *param_string = "c:im:"; while ((c = pgetopt(argc, argv, param_string, "$Revision: 1.7 $", _SRC_)) != -1) switch(c) { case 'c': c_flag = TRUE; comment = poptarg; break; case 'i': i_flag = TRUE; break; case 'm': m = atof(poptarg); break; case '?': params_to_usage(cerr, argv[0], param_string); get_help(); exit(1); } node * root; root = new node(); root->set_root(root); root->set_mass(m); if (c_flag == TRUE) root->log_comment(comment); root->log_history(argc, argv); if (i_flag) root->set_label(1); put_node(root); rmtree(root); }
int main(int argc, char **argv) { FILE *f,*fb; int number_of_elements_text_file=0,number_of_elements_binary_file=0; fb = open_file(spis_1,"w+b"); f = open_file(spis_2,"w+"); char* file_name = (char *) calloc(10, sizeof(char)); char* binary_file_name = (char *) calloc(10, sizeof(char)); if (argc == 3) { strcpy(file_name, argv[1]); strcpy(binary_file_name, argv[2]); } char choice; while(1) { choice = menu_select(); switch(choice) { case 1 : number_of_elements_text_file = loading_the_text_file(file_name); number_of_elements_binary_file = loading_the_binary_file(binary_file_name); break; case 2 : print_bin_file( binary_file_name, number_of_elements_binary_file); printf ("\n"); printf_txt_file(file_name, number_of_elements_text_file); printf ("\n"); break; case 3 : search_of_the_same_elem(file_name , number_of_elements_text_file, binary_file_name, number_of_elements_binary_file); break; case 4 : exit(0); break; case 5 : check_help(); break; } } }
main(int argc, char **argv) { dyn *root; int e_flag = 0; real eps = 0; check_help(); extern char *poptarg; int c; const char *param_string = "e:"; while ((c = pgetopt(argc, argv, param_string, "$Revision: 1.6 $", _SRC_)) != -1) switch(c) { case 'e': e_flag = 1; eps = atof(poptarg); break; case '?': params_to_usage(cerr, argv[0], param_string); get_help(); exit(1); } // Loop over input until no more data remain. while ( (root = get_dyn()) != NULL) { real kinetic_energy, potential_energy; get_top_level_energies(root, eps*eps, potential_energy, kinetic_energy); cout << "Top-level energies (T, U, E): " << kinetic_energy << " " << potential_energy << " " << kinetic_energy + potential_energy << endl; } }
main(int argc, char ** argv) { char *comment; bool c_flag = FALSE; // if TRUE, a comment given on command line real t_extract; bool t_flag = FALSE; // if TRUE, a time was specified bool v_flag = FALSE; // if TRUE, print snap times as read int n = 1; bool n_flag = false; // if TRUE, a number was specified check_help(); extern char *poptarg; int c; const char *param_string = "c:n:t:v"; while ((c = pgetopt(argc, argv, param_string, "$Revision: 1.8 $", _SRC_)) != -1) switch(c) { case 'c': c_flag = TRUE; comment = poptarg; break; case 't': t_flag = TRUE; t_extract = atof(poptarg); break; case 'n': n_flag = TRUE; n = atoi(poptarg); break; case 'v': v_flag = TRUE; break; case '?': params_to_usage(cerr, argv[0], param_string); get_help(); exit(1); } if (n < 0) err_exit("n < 0 specified."); if (n > 1 && !t_flag) { warning("n > 1 but no time specified -- 0 assumed."); t_extract = 0; t_flag = true; } node *b = NULL, *bp = NULL; int i = 0; // Need to ensure that the data are not changed by this function. // Currently, get_dyn() ends by calling check_and_correct_node(), // which may change pos and vel to force the system to the center // of mass frame. Can fix (1) by suppressing this call in this // case, (2) setting a tolerance to avoid forcing if the system is // already "close" to the CM frame, or (3) use nodes here, which // will never interpret pos or vel and hence will not change them. // The only number we really need below is sytsem_time. Options // (1) and (2) are awkward, because this function is a member // function and changing its arguments would propagate through the // other classes. However, we could add a static local option to // the dyn instance of the function. Option (3) seems cleanest. // To revert, change node to dyn and use b->get_system_time() to // determine time. // (Steve, 7/04) while (b = get_node()) { real time; if (find_qmatch(b->get_dyn_story(), "real_system_time")) time = getrq(b->get_dyn_story(), "real_system_time"); else time = getrq(b->get_dyn_story(), "system_time"); // real time = b->get_system_time(); i++; if (v_flag) cerr << "Snap time #" << i << " = " << time << endl; if (t_flag && time >= t_extract) { if (n > 0) { if (c_flag == TRUE) b->log_comment(comment); b->log_history(argc, argv); put_node(b); } if (--n <= 0) exit(0); } if (bp) rmtree(bp); bp = b; } if (n > 0 && !t_flag) { bp->log_history(argc, argv); put_node(bp); } }
main(int argc, char ** argv) { bool renumber = true; check_help(); extern char *poptarg; extern char *poparr[]; int c; const char *param_string = "n"; // Parse the argument list: while ((c = pgetopt(argc, argv, param_string, "$Revision: 1.8 $", _SRC_)) != -1) { switch (c) { case 'n': renumber = false; break; default: case '?': params_to_usage(cerr, argv[0], param_string); get_help(); return false; } } dyn *b, *root = new dyn; if (!root) err_exit("merge_snaps: can't create root node."); int count = 0; root->log_history(argc, argv); while (b = get_dyn()) { b->offset_com(); // add root pos/vel to daughters // Attach top-level nodes of b to root. dyn *last = root->get_oldest_daughter(); while (last && last->get_younger_sister()) last = last->get_younger_sister(); for_all_daughters(dyn, b, bb) { // First node is a special case. if (!last) root->set_oldest_daughter(bb); else last->set_younger_sister(bb); bb->set_elder_sister(last); bb->set_parent(root); last = bb; } // Merge the root log stories, with a prefix indicating which // initial snapshot this was. This code is not completely general, // but should be sufficient for simple (typical) stories. story *sr = root->get_log_story(); story *s = b->get_log_story(); for (story * d = s->get_first_daughter_node(); d != NULL; d = d->get_next_story_node()) if (!d->get_chapter_flag()) { char tmp[1024]; sprintf(tmp, " +%4.4d: ", count); strncat(tmp, d->get_text(), 1013); tmp[1023] = '\0'; add_story_line(sr, tmp); } count++; delete b; } // Recompute the total mass and force the center of mass to 0. // Better renumber too, unless specifically suppressed.. real mass = 0; int index = 0; for_all_daughters(dyn, root, bb) { mass += bb->get_mass(); if (renumber) bb->set_index(++index); }
int main(int argc, char ** argv) { real lower = 1.0, upper = 1.0; real emax = 1; int function_select = 3; int option = 1; int random_seed = 0; char seedlog[64]; check_help(); extern char *poptarg; int c; const char *param_string = "f:l:s:o:u:e:"; while ((c = pgetopt(argc, argv, param_string, "$Revision: 1.9 $", _SRC_)) != -1) switch(c) { case 'f': function_select = atoi(poptarg); break; case 'l': lower = atof(poptarg); break; case 'o': option= atoi(poptarg); break; case 'e': emax = atof(poptarg); break; case 's': random_seed = atoi(poptarg); break; case 'u': upper = atof(poptarg); break; case '?': params_to_usage(cerr, argv[0], param_string); get_help(); exit(1); } if (lower <= 0 || upper <= 0 || lower > upper) err_exit("makebinary: Illegal limits"); dyn* b; b = get_dyn(); b->log_history(argc, argv); int actual_seed = srandinter(random_seed); sprintf(seedlog, " random number generator seed = %d", actual_seed); b->log_comment(seedlog); // Look in the dyn story to see if a total system energy is known. // If it is, scale lower and upper accordingly. // Thus, in case function_select = 3, if the energy is known, // lower and upper are specified in "kT" units. If the energy // is not known, lower and upper are absolute limits on the // binary kinetic energy. const char* energy_string = "initial_total_energy"; if (function_select == 1) { if (b->get_starbase()->get_stellar_evolution_scaling()) { real scale = sqrt(b->get_starbase()->conv_m_star_to_dyn(1) * b->get_starbase()->conv_r_star_to_dyn(1)); lower *= scale; upper *= scale; } else cerr << "makebinary: Using unscaled angular-momentum limits.\n"; } else if (function_select == 2) { if (b->get_starbase()->conv_r_star_to_dyn(1)>0) { lower = b->get_starbase()->conv_r_star_to_dyn(lower); upper = b->get_starbase()->conv_r_star_to_dyn(upper); } else cerr << "makebinary: Using unscaled semi-major axis limits.\n"; } else if (function_select == 3) { if (find_qmatch(b->get_log_story(), energy_string)) scale_limits(lower, upper, option, b->n_daughters(), b->get_mass(), getrq(b->get_log_story(), energy_string)); else cerr << "makebinary: Using unscaled energy limits.\n"; } makebinary(b, lower, upper, function_select, option, emax); put_dyn(b); rmtree(b); return 0; }