//TODO: Can eventually remake it so that it makes a temporary list to search through void print_topleft() { int max_n; if(board.size > 10) max_n = 10; else max_n = board.size; for(int i = 0; i < max_n; i++) { for(int j = 0; j < max_n; j++) { bool found = false; unit_list_elem_ptr unit_list_temp = board.player_1_list; while(unit_list_temp != null && !found) { if(unit_list_temp->unit->x == j && unit_list_temp->unit->y == i) { found = true; print_unit(unit_list_temp->unit); } unit_list_temp = unit_list_temp->next; } unit_list_temp = board.player_2_list; while(unit_list_temp != null && !found) { if (unit_list_temp->unit->x == j && unit_list_temp->unit->y == i) { found = true; print_unit(unit_list_temp->unit); } unit_list_temp = unit_list_temp->next; } if(!found) fprintf(stdout, "."); } fprintf(stdout, "\n"); } fprintf(stdout, "\n"); }
int main(int argc, char *argv[]) { strcpy(act_info.prog_id,argv[0]); //creep_capacity = 10; // strcpy(act_info.prog_id,argv[0]); strcpy(date, argv[1]); init_prog(); printf("here\n"); get_unit_info(); get_limit(); check(); init_to_downlimit_power(); print_unit("用最小出力初始化电厂出力后打印"); cal_unit_gen(); printf("\n\n\n"); //write_act_info( 1, "执行定电量负荷分配程序成功"); free_memory(); close_database(); printf("\n\n"); }
/* * Display inodes *@files: number of inodes *@favail: number of available inodes */ static void text_disp_inodes(uint64_t files, uint64_t favail) { int i; if (unitflag == 'h') { i = humanize_i(&files); (void)printf("%*" PRIu64, max.nbinodes - 1, files); print_unit(i, 0); i = humanize_i(&favail); (void)printf("%*" PRIu64, max.avinodes - 1, favail); print_unit(i, 0); } else { (void)printf(" %*" PRIu64, max.nbinodes - 1, files); (void)printf(" %*" PRIu64, max.avinodes - 1, favail); } }
int main(int argc, char * argv[]) { char map[10][10] = { {1,1,1,1,1,1,1,1,1,1}, {1,0,0,0,0,0,0,0,0,1}, {1,0,0,1,0,1,0,1,0,1}, {1,1,1,1,1,1,0,1,0,1}, {1,0,0,0,0,0,0,1,0,1}, {1,0,0,1,0,1,1,1,1,1}, {1,0,1,1,0,0,0,0,0,1}, {1,0,0,0,1,0,1,1,1,1}, {1,0,1,0,1,0,0,0,0,1}, {1,1,1,1,1,1,1,1,1,1} }; while (1) { if (judgment() == 1) break; print_unit(map); shift(map); } print_unit(map); printf("GOAL~!!\n"); system("pause"); }
/* * Display inodes *@files: number of inodes *@favail: number of available inodes */ static void html_disp_inodes(uint64_t files, uint64_t favail) { int i; if (unitflag == 'h') { i = humanize_i(&files); (void)printf("\t <td style = \"text-align: right;\">%" PRIu64, files); print_unit(i, 0); (void)printf("</td>\n"); i = humanize_i(&favail); (void)printf("\t <td style = \"text-align: right;\">%" PRIu64, favail); print_unit(i, 0); (void)printf("</td>\n"); } else { (void)printf("\t <td style = \"text-align: right;\">%" PRIu64 "</td>\n", files); (void)printf("\t <td style = \"text-align: right;\">%" PRIu64 "</td>\n", favail); } }
/* * Display used, available and total correctly formatted * @n: number to print * @perct: percentage (useful for finding which color to use) * @req_width: required width (used for terminal display, otherwise can be 0) */ static void text_disp_uat(double n, double perct, int req_width) { int i; i = 0; if (unitflag == 'h') i = humanize(&n); change_color(perct); (void)printf("%*.1f", req_width - 1, n); /* -1 for the unit symbol */ reset_color(); print_unit(i, 1); }
void *thread_worker(void* arg) { struct timespec start, stop; int i; unsigned long long delta; unsigned long long min=-1, max=0; stats_container_t dat; stats_record_t rec; stats_container_init(&dat, NUMRUNS); for (i=0; i < NUMRUNS; i++) { do_work(1); /* warm cache */ /* do test */ clock_gettime(CLOCK_MONOTONIC, &start); do_work(NUMLOOPS); clock_gettime(CLOCK_MONOTONIC, &stop); /* calc delta, min and max */ delta = ts_sub(stop, start); if (delta < min) min = delta; if (delta> max) max = delta; rec.x = i; rec.y = delta; stats_container_append(&dat, rec); printf("delta: %llu ns\n", delta); usleep(1); /* let other things happen */ } printf("max jitter: "); print_unit(max - min); stats_container_save("samples", "Scheduling Jitter Scatter Plot",\ "Iteration", "Delay (ns)", &dat, "points"); return NULL; }
/* * Display available and total correctly formatted * @n: number to print * @perct: ignored here * @req_width: ignored here */ static void html_disp_uat(double n, double perct, int req_width) { int i; (void)perct; (void)req_width; (void)printf("\t <td style = \"text-align: right;\">"); if (unitflag == 'h') { i = humanize(&n); (void)printf(i == 0 ? "%.f" : "%.1f", n); print_unit(i, 1); } else { if (unitflag == 'b' || unitflag == 'k') (void)printf("%.f", n); else (void)printf("%.1f", n); } (void)puts("</td>"); }
static void print_current(u_int ii) { print_unit(ii / 10, "um", 'A'); }
static void print_volt(u_int vi) { print_unit(vi * 10, "um", 'V'); }
static void print_time(u_int tm, u_long scale) { print_unit(tm * scale, "num", 's'); }