void start(int diff) { STRU_B board[M][N]; char drection = RIGHT; int isn_lose = 1, i, dc; initialise_board(board); creat_sanke(board); while (isn_lose) { dc = 0; system("CLS"); show_board(board); for (i = 0; i < diff; i++) { if (GetKeyState(VK_UP) < 0 && drection != DOWN && dc == 0) drection = UP, dc++; if (GetKeyState(VK_DOWN) < 0 && drection != UP && dc == 0) drection = DOWN, dc++; if (GetKeyState(VK_LEFT) < 0 && drection != RIGHT && dc == 0) drection = LEFT, dc++; if (GetKeyState(VK_RIGHT) < 0 && drection != LEFT && dc == 0) drection = RIGHT, dc++; Sleep(10); } isn_lose = move_snake(board, drection); } system("CLS"); show_board(board); }
int main (void) { int i; initialise_board (); start_trigger (); for (i = 0; i < SCALE_FACTOR; i++) benchmark (); stop_trigger (); return 0; }
int main() { int n; initialise_board(); start_trigger(); for(n = 0; n < SCALE_FACTOR; ++n) { benchmark(); } stop_trigger(); return 0; }
int main() { int i; long int n; /* We can only do a check with 1 or 4096 transformations. */ short int check_block_1 [64] = { 699, 164, -51,- 16, 31, -15, -19, 8, 71, 14, -61, -2, 11, -12, 7, 12, -58, -55, 13, 28, -20, -7, 14, -18, 29, 22, 3, 3, -11, 7, 11, -22, -1, -28, -27, 10, 0, -7, 11, 6, 7, 6, 21, 21, -10, -8, 2, -14, 1, -7, -15, -15, -10, 15, 16, -10, 0, -1, 0, 15, 4, -13, -5, 4 }; short int check_block_4096 [64] = { -2480, -665, -689, 44, -350, 26, -272, -535, -628, -2044, -544, 141, 300, -147, -1, 89, -676, -551, -1820, 224, 267, -154, -281, -290, 52, 149, 262, -1508, -228, -102, 58, 100, -425, 342, 148, -185, -2485, 802, 227, -750, 34, -62, -225, -84, 829, -1495, -172, 319, -171, -14, -367, 67, 323, -127, -1400, 28, -546, 38, -355, 159, -750, 316, -4, -1849 }; short int *check_block; int to_return; initialise_board (); start_trigger(); for(n = 0; n < SCALE_FACTOR; ++n) fdct (block, 8); /* 8x8 Blocks, DC precision value = 0, Quantization coefficient (mquant) = 64 */ stop_trigger(); /* Verify if we can */ to_return = 0; check_block = (1 == SCALE_FACTOR) ? check_block_1 : (4096 == SCALE_FACTOR) ? check_block_4096 : NULL; if (NULL != check_block) for (i = 0; i < 64; i++) if (block[i] != check_block[i]) { to_return = -1; break; } return to_return; }
int main(int argc, char *argv[]) { unsigned char ukey[8]; unsigned char indata[40],outdata[40],ivec[8] = {0}; unsigned char check_outdata[40] = { -11, 25, 13, -69, -45, -32, 31, 46, -77, -34, 57, -26, 1, -125, -65, 119, 67, -82, -23, -42, -47, 51, 15, 71, 83, 30, 89, -58, 33, 67, -97, 87, -61, -114, -87, -42, -111, -45, 15, 71 }; int num; int by=0,i=0; int encordec=-1; char *cp,ch; int n, n2; initialise_board(); start_trigger(); for(n = 0; n < SCALE_FACTOR; ++n) { encordec = 1; num=0; /* Read the key */ cp = ckey; while(i < 64 && *cp) /* the maximum key length is 32 bytes and */ { /* hence at most 64 hexadecimal digits */ ch = *cp++; /* process a hexadecimal digit */ if(ch >= '0' && ch <= '9') by = (by << 4) + ch - '0'; else if(ch >= 'A' && ch <= 'F') by = (by << 4) + ch - 'A' + 10; else /* error if not hexadecimal */ { // printf("key must be in hexadecimal notation\n"); exit(-1); } /* store a key byte for each pair of hexadecimal digits */ if(i++ & 1) ukey[i / 2 - 1] = by & 0xff; } BF_set_key(&key,8,ukey); if(*cp) { //printf("Bad key value.\n"); exit(-1); } i=0; for(n2 = 0; n2 < 256; ++n2) { while(i<40) indata[i++]=rand(); BF_cfb64_encrypt(indata,outdata,i,&key,ivec,&num,encordec); encordec = 1-encordec; BF_cfb64_encrypt(outdata,indata,i,&key,ivec,&num,encordec); i=0; } } stop_trigger(); /* Verify that we have the correct result. */ int to_return = 0; for (i = 0; i < 40; i++) { if (outdata[i] != check_outdata[i]) { to_return = -1; break; } } return to_return; }
int main(void) { double a1 = 1.0, b1 = -10.5, c1 = 32.0, d1 = -30.0; double a2 = 1.0, b2 = -4.5, c2 = 17.0, d2 = -30.0; double a3 = 1.0, b3 = -3.5, c3 = 22.0, d3 = -31.0; double a4 = 1.0, b4 = -13.7, c4 = 1.0, d4 = -35.0; int solutions; int i; long n = 0; double output[48] = {0}; double *output_pos = &(output[0]); int output_count = 0; int check_output[48] = {-9, 0, -0, -9, 0, -0, -9, 0, -0, -9, 0, -0, -8, 0, -0, -8, 0, -0, -8, 0, -0, -8, 0, -0, -4, 0, -0, -4, 0, -0, -4, 0, -0, -4, 0, -0, -3, 0, -0, -3, 0, -1, -3, 0, -0, -3, 0, -1}; initialise_board(); start_trigger(); for(n = 0; n < SCALE_FACTOR; ++n) { /* solve some cubic functions */ /* should get 3 solutions: 2, 6 & 2.5 */ SolveCubic(a1, b1, c1, d1, &solutions, output); /* should get 1 solution: 2.5 */ SolveCubic(a2, b2, c2, d2, &solutions, output); SolveCubic(a3, b3, c3, d3, &solutions, output); SolveCubic(a4, b4, c4, d4, &solutions, output); /* Now solve some random equations */ for(a1=1;a1<3;a1++) { for(b1=10;b1>8;b1--) { for(c1=5;c1<6;c1+=0.5) { for(d1=-1;d1>-3;d1--) { SolveCubic(a1, b1, c1, d1, &solutions, output_pos); output_pos += solutions; output_count += solutions; } } } } } stop_trigger(); /* Verify that we have the correct result. */ int to_return = 0; for (i = 0; i < output_count; i++) { if ((int) output[i] != check_output[i]) { to_return = -1; break; } } return to_return; }
/* @param human a pointer to details about the human player * @param computer a pointer to details about the computer player **/ struct player* play_game(struct player *human , struct player *computer) { /* Function for controlling game */ /* declaration that allocates the board for the game */ enum cell_contents board[BOARDHEIGHT][BOARDWIDTH]; enum game_state check_winner; /* variable for storing current player */ struct player *current; struct player *other; /* initialize the game board */ initialise_board(board); /* display the game board before turn */ display_board(board); /* determine current player (white goes first) */ if (human->thiscolor == C_WHITE) { current = human; other = computer; printf("\n%s\n", "Human goes first"); } else { current = computer; other = human; printf("\n%s\n", "Computer goes first"); } /* human and computer take a turn * until winner found then loop exit. * */ while(TRUE) { /* pointer to current player passed to take turn function */ take_turn(current, board); /* board is displayed after turn is made to show changes */ display_board(board); /* run the test for winner function and save result in variable * for saving latest winner state */ check_winner = test_for_winner(board); if (check_winner == G_RED) { printf("\nRED CONNECTED 4!\n"); printf("\n%s%s\n", "You win: ", current->name); return current; } else if (check_winner == G_WHITE) { printf("\nWHITE CONNECTED 4!\n"); printf("\n%s%s\n", "You win: " , current->name); return current; } /* swap current players using pointer swap */ swap_players(¤t, &other); printf("\n%s%s\n", "Current player is: " , current->name ); } return NULL; }