int main(int argc, char* argv[]) { if (argc > 1) { work_package_t work_package; for (int i = 1; i < argc; ++i) { if (strcmp("-data", argv[i]) == 0) work_package.file_cmp_options.file_data = false; else if (strcmp("-name", argv[i]) == 0) work_package.file_cmp_options.file_name = false; else if (strcmp("+data", argv[i]) == 0) work_package.file_cmp_options.file_data = true; else if (strcmp("+name", argv[i]) == 0) work_package.file_cmp_options.file_name = true; else { fs::path p(argv[i]); if (fs::exists(p)) { find_duplicate(p, work_package); } } } reduce_result(work_package); print_reduced_result(work_package); } return 0; }
int main() { /* simple test */ int i; srand(clock()); for(i = 0; i < 10; i++) { int a[] = {1,2,3,4,5,6,7,8,8}; shuffle(a,NELEMS(a)); assert(8 == find_duplicate(a,NELEMS(a))); } return 0; }
//------------------------------------------------------------------------------ void add_to_history(const char* line) { int dupe_mode; const unsigned char* c; // Maybe we shouldn't add this line to the history at all? c = (const unsigned char*)line; if (isspace(*c) && get_clink_setting_int("history_ignore_space") > 0) { return; } // Skip leading whitespace while (*c) { if (!isspace(*c)) { break; } ++c; } // Skip empty lines if (*c == '\0') { return; } // Check if the line's a duplicate of and existing history entry. dupe_mode = get_clink_setting_int("history_dupe_mode"); if (dupe_mode > 0) { int where = find_duplicate(c); if (where >= 0) { if (dupe_mode > 1) { remove_history(where); } else { return; } } } // All's well. Add the line. using_history(); add_history(line); ++g_new_history_count; }
int main() { //initialize test data int array[10] ={1,2,5,8,5,5,9,3,7,6}; int item = find_duplicate(array,10); if (item == -1) { printf("failed"); return -1; } if (item == -2) { printf("There is no duplicate value"); return -2; } printf("the item %d has duplicate value",item); }
parsing_result_type_t parseSimulation(xmlNode * node, CONTEXT * ctx) { ctx->simspec = calloc(1, sizeof(st_simspec)); char *type_str; if ( getStr(node, "signal_type", &type_str) && getInt(node, "signal_no", &ctx->simspec->signal_no, PARSER_REQUIRED) && getInt(node, "bit_length", &ctx->simspec->bit_length, PARSER_REQUIRED) ) { if ( find_duplicate(ctx, ctx->simspec->signal_no, ctx->simspec->bit_length) ) { printf("Duplicate signal number %d (bit_length %d) for device %s (position %d)\n", ctx->simspec->signal_no, ctx->simspec->bit_length, ctx->device->name, ctx->device->position); assert(0); } ctx->simspec->type = parseStType(type_str); return parseParams(node, ctx->simspec) && ( ctx->simspec->parent = ctx->device ) && ellAddOK(&ctx->device->simspecs, &ctx->simspec->node); } else return PARSING_ERROR; }