void print_array_stat(const struct module *mod, const double *st_array) { int i; struct mod_info *info = mod->info; for (i = 0; i < mod->n_col; i++) { if (mod->spec) { /* print null */ if (!st_array || !mod->st_flag || st_array[i] < 0) { /* print record */ if (((DATA_SUMMARY == conf.print_mode) && (SPEC_BIT == info[i].summary_bit)) || ((DATA_DETAIL == conf.print_mode) && (SPEC_BIT == info[i].summary_bit))) { printf("------%s", PRINT_DATA_SPLIT); } } else { /* print record */ if (((DATA_SUMMARY == conf.print_mode) && (SPEC_BIT == info[i].summary_bit)) || ((DATA_DETAIL == conf.print_mode) && (SPEC_BIT == info[i].summary_bit))) { printf_result(st_array[i]); } } } else { /* print null */ if (!st_array || !mod->st_flag || st_array[i] < 0) { /* print record */ if (((DATA_SUMMARY == conf.print_mode) && (SUMMARY_BIT == info[i].summary_bit)) || ((DATA_DETAIL == conf.print_mode) && (HIDE_BIT != info[i].summary_bit))) { printf("------%s", PRINT_DATA_SPLIT); } } else { /* print record */ if (((DATA_SUMMARY == conf.print_mode) && (SUMMARY_BIT == info[i].summary_bit)) || ((DATA_DETAIL == conf.print_mode) && (HIDE_BIT != info[i].summary_bit))) { printf_result(st_array[i]); } } } } }
int main(int argc, const char *argv[]) { int array[M]; init_array(array , M); printf_array(array , M); delete_same_data(array , M); printf_array(array , M); printf("\n"); printf_result(array , M); return 0; }
void print_tail(int tail_type) { int i, j, k; double *m_tail; struct module *mod = NULL; switch (tail_type) { case TAIL_MAX: printf("MAX %s", PRINT_SEC_SPLIT); break; case TAIL_MEAN: printf("MEAN %s", PRINT_SEC_SPLIT); break; case TAIL_MIN: printf("MIN %s", PRINT_SEC_SPLIT); break; default: return; } /* print summary data */ for (i = 0; i < statis.total_mod_num; i++) { mod = &mods[i]; if (!mod->enable) { continue; } switch (tail_type) { case TAIL_MAX: m_tail = mod->max_array; break; case TAIL_MEAN: m_tail = mod->mean_array; break; case TAIL_MIN: m_tail = mod->min_array; break; default: return; } k = 0; for (j = 0; j < mod->n_item; j++) { if (*mod->print_item != 0 && (mod->p_item & (1<<j)) == 0) { k += mod->n_col; continue; } int i; struct mod_info *info = mod->info; for (i=0; i < mod->n_col; i++) { /* print record */ if (mod->spec) { if (((DATA_SUMMARY == conf.print_mode) && (SPEC_BIT == info[i].summary_bit)) || ((DATA_DETAIL == conf.print_mode) && (SPEC_BIT == info[i].summary_bit))) { printf_result(m_tail[k]); } } else { if (((DATA_SUMMARY == conf.print_mode) && (SUMMARY_BIT == info[i].summary_bit)) || ((DATA_DETAIL == conf.print_mode) && (HIDE_BIT != info[i].summary_bit))) { printf_result(m_tail[k]); } } k++; } printf("%s", PRINT_SEC_SPLIT); } if (mod->n_item != 1) { if (!m_tail) { print_array_stat(mod, NULL); } printf("%s", PRINT_SEC_SPLIT); } } printf("\n"); }