[My early C program source code] black and white chess

xiaoxiao2021-03-06  20

/ * The program is not perfect enough * /

#include #include #include #include #include #include #include # Include #include #include #include

#define hh '0' # Define n 6int q = 0; char key; int fix = 1; int A = 0, b = 0; char s [n] [n], m [n] [n]; void * Ball; int maxX; unsigned int size; loading () {int z = 1;

While (z) {if (z> 77) Break; Printf ("<"); delay (5000); z ;} delay (2000); cleardevice ();

} Unsigned char GET_ASCII_KEY (VOID) {IF (Bioskey (0)); Else Return (0);} INT TEST_ASCII_KEY (INT ASCII) {IF (GET_ASCII_Key () == ASCII) Return (1) Elsereturn (0); Void Tu () {maxx = getmaxx (); size = imageSize (210, 390, 450, 420); ball = malloc (size); setFillStyle (1, 10); bar (160, 170, 473, 253); setfillstyle (1, 9) Bar (163, 173, 470, 250); SetColor (13); Outtextxy (200, 200, "Welcome to Black & White Chess"); setColor (14); Outtextxy (250, 220, "developer: wu silk"); Outtextxy (290, 240, "2002.8") Outtextxy (210, 390, "Press Any Key to Contunue ..."); GetImage (210, 390, 450, 420, ball);

While (! kbhit ()) {PUTIMAGE (210, 390, Ball, XOR_PUT); DELAY (30000);

ClearDevice (); void sou (void) {

} void print () {INT i = 0, J = 30; setColor (11); Outtextxy (35, 20, "0 1 2 3 4 5"); OUTTEXTXY (14, 50, "0"); OutTextxy (14,100 , "1"); Outtextxy (14, 150, "2"); OutTextxy (14, 250, "4"); OutTextxy (14, 300, "5"); setBkcolor (0); setLinesTyle (Solid_Line , 0, 2); for (i = 0; i <7; i ) {setColor (Green); line (j, 30, j, 330); j = 50;} j = 30; for (i = 0; I <7; i ) {setColor (Green); line (30, j, 330, j); j = 50;

} for (i = 0; i <6; i ) for (j = 0; j <6; j ) {IF (S [i] [j] == 'o')

{SetColor (White); Circle (55 J * 50, 55 i * 50, 15);} else if (s [i] [j] == 'x') {setColor (red); Circle (55 J * 50, 55 i * 50, 15);}}

}

INT CAL (CHAR Z) {INT * P = 0; int Num = 0, I, J; for (i = 0; i

Void Load () {INT I, J; For (i = 0; i

SNEW (int X, int y, char z1, char z2) {INT I, J, A; int CAN [] = {0, 0, 0, 0, 0, 0, 0, 0, 0}, K [N * N]; if (s [x] [Y-1] == Z1 && (Y-1)> = 0) {i = 0; While (I = 0) {i = 0; While (I = 0) {i = 2; while (Y i = 0)) {IF (S [xi] [y i] == z2) {can [5] = 1; Break;} i ;}} = f (s [x 1] [y-1] == z1 && (y-1)> = 0) {i = 2; while (i = 0)) {if (s [x i] [yi] == z2) {can [6] = 1; Break;} i ;}} IF (s [x-1] [Y-1] == Z1 && (X-1) * (Y-1)> = 0) {i = 2; While (xi> = 0 && y-i> = 0) {IF (S [xi] [yi] == Z2) {can [7] = 1; Break;} i ;}} = f (s [x 1] [y 1] == z1) {i = 2; While (i x

IF (CAN [1] == 1) {i = 1; while (s [x] [yi] == z1) {s [x] [yi] = Z2; i ;} can [1] = 0; IF (CAN [2] == 1) {i = 1; while (s [x] [y i] == z1) {s [x] [y i] = z2; i ;} can [2] = 0;}} (can [3] == 1) {i = 1; while (s [xi] [y] == z1) {s [xi] [y] = z2; i ;} can [3] = 0;} IF (CAN [4] == 1) {i = 1; while (s [x i] [y] == z1) {s [x i] [y] = z2; i ;} CAN [4] = 0;} IF (CAN [5] == 1) {i = 1; while (s [xi] [y i] == z1) {s [xi] [y i] = Z2 I ;} can [5] = 0;} if (can [6] == 1) {i = 1; while (s [x i] [yi] == z1) {s [x i] [ Yi] = z2; i ;} can [6] = 0;} IF (can [7] == 1) {i = 1; while (s [xi] [yi] == z1) {s [xi] [ Yi] = z2; i ;} can [7] = 0;} IF (can [8] == 1) {i = 1; while (s [x i] [y i] == z1) {s [x i] [y i] = z2; i ;} can [8] = 0;}} / * snew * /

Void One () {Int A, B; Char g = 'o';

Load (); setColor (15); Printf ("/ n / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N / N "); Printf (" / N to EXIT THE GAME PRESS The 'Q' KEY./N "); Print ();

Printf ("Please INPUT X (0 to 5):"); while (1) {

A = GET_ASCII_KEY ();

IF (a == 113 || a == 81) {printf ("/ nquit? (y OR N)"); while (1) {if (Test_ascii_key (89) || Test_ascii_key (121)) EXIT (0) ELSE IF (Test_ascii_Key (110) || Test_ascii_key (78)) {Printf ("/ N / Twelcome To Return THE GAME! / N"); Break;}}}

IF (A> = 48 && a <= 53) {Printf ("/ tgood! x HAS get! / n"); Break;}} a = a-48; Printf ("please input y (0 to 5):") ;

While (1) {

B = get_ascii_key (); if (b == 113 || b == 81) {printf ("/ nquit? (y)"); while (1) {i (Test_ascii_key (89) || Test_ascii_key (121 )) EXIT (0); Else IF (TEST_ASCII_Key (110) || Test_ascii_key (78)) Break;

}}} F (b> = 48 && a <= 53) {Printf ("/ tgood! Y HAS get!"); Break;}} b = b-48;

Q = 1; SNEW (A, B, 'x', 'o'); Q = 0; save ();

A = CAL (g); b = CAL ('x'); / * Printf ("/ T / T / T / T / T / T / T / RA =% D, B =% D", A, B); * /

} / * one * / void search () {INT i, j, r = 0; for (i = 0; i

} void two () {char h = 'x'; int Row [n * n], col [n * n]; int A = 1, II, J, T, T1, K [N * n]; load ( ); For (ii = 0; II

For (II = 1; II

} T = k [1]; II-; T1 = II; While (II) {IF (t <= k [ii]) {t = k [ii]; t1 = ii;} ii--;} a = T1; a = CAL ('o'); b = T; loading ();

SNEW (Row [A], Col [A], 'O', 'X'); Save (); ClearDevice ();

Printf ("/ N / N / T / T / T / T / T / T COMPUTER LOCATED:% D,% D", ROW [A], COL [A]);

}

Main () {INT I, J; INT GD = Detect, GM; ClrsCr (); Initgraph (& GD, & GM, "D: // TC // BGI");

Setbkcolor (Black);

Tu ();

Sou (); setbkcolor (0);

For (i = 0; i

While (Fine)

{Print (); one (); two (); search (); if (key == 113 || key == 81) {printf ("/ nquit? (Y)"); while (! Test_ascii_key) 89) &&! Test_ascii_key (121)); Break;}} IF (A> B) OutTextxy (400, 200, "You win!"); ELSE IF (a

转载请注明原文地址:https://www.9cbs.com/read-48044.html

New Post(0)