亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ttt.c

?? 該程序是C語言編寫的
?? C
字號:
/*----------------------------------------------------*- Fundamental -*-

Facility:		ttt(6)

File:			ttt.c

Associated files:	- [ none]

Description:		Plays the game of tic-tac-toe.

Author:			Leor Zolman

Editor:			Anders Thulin
			Rydsvagen 288
			S-582 50 Linkoping
			SWEDEN

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Edit history :

Vers  Ed   Date	       By                Comments
----  ---  ----------  ----------------  -------------------------------
 1.0    0  1979-09-xx  Leor Zolman	 Written in BDS C
 1.1    1  1988-10-25  Anders Thulin     Added some comments; cleaned
				         up generally

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

/*---  Configuration:  --------------------------------------------------

System configuration options:
=============================

Symbol:		Conformant systems:
	
ANSI		ANSI C
BSD		BSD Unix, SunOS 3.5
SV2		AT&T UNIX System V.2, AU/X
XPG3		X/Open Portability Guide, ed. 3

If you have an ANSI C compiler, define ANSI. If not, choose one
of the other symbols.

There are no program configuration options.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

#define	ANSI	1
#define	BSD	0
#define	SV2	0
#define	XPG3	0

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#if ANSI
# include <ctype.h>
# include <stdio.h>
# include <stdlib.h>
#endif

#if BSD
# include <ctype.h>
# include <stdio.h>
  extern int rand();
  extern int srand();		/* SunOS srand returns int? */
# define EXIT_FAILURE	1
# define EXIT_SUCCESS	0
#endif

#if SV2
# include <ctype.h>
# include <stdio.h>
  extern int  rand();
  extern void srand();
# define EXIT_FAILURE	1
# define EXIT_SUCCESS	0
#endif

#if XPG3
# include <ctype.h>
# include <stdio.h>
# include <stdlib.h>
#endif

/*---  Original comments to program:  ----------------------------------

BD Software presents:

Tic Tac Toe  (by exhaustive search)

written by Leor Zolman
September 1979

This program was written for use as the crux of an article in BYTE
(as yet to be published) on BDS C, structured programming and gaming.

It is also intended to get you addicted to C so you'll go out and buy
the BD Software C Compiler

only $110 on CP/M disk from:

 	tiny c associates
	post office box 269
	holmdel, new jersey 07733

The package includes the compiler, linking loader, library manager,
standard library of functions, many interesting sample programs (such as
"TELNET.C" for using your computer as a terminal and allowing I/O directly
from modem to disk and vice-versa.) Also included is a copy of the best
reference book available on the C language, written by the original
implementors at Bell Labs (the package may be purchased without the book
for $100.)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

#define	TRUE	1
#define	FALSE	0

#define	X	1	/* The pieces on the board */
#define O	5
#define EMPTY	0

char board[9];		/* the playing board */
char BEST;		/* move returned by "ttteval" */

int wins[8][3] = {	/* table of winning positions */
	{0,1,2},
	{3,4,5},
	{6,7,8},
	{0,3,6},
	{1,4,7},
	{2,5,8},
	{0,4,8},
	{2,4,6}
     };

/*----------------------------------------------------------------------
  Local functions:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#if __STDC__ != 0
 static int  ask(char *s);
 static int  cats(void);
 static void clear(void);
 static void display(void);
 static int  getmove(void);
 static int  ttteval(int me, int him);
 static int  win(int p);
#else
 static int  ask();
 static int  cats();
 static void clear();
 static void display();
 static int  getmove();
 static int  ttteval();
 static int  win();
#endif

/*----------------------------------------------------------------------

Routine:	ask

Description:	writes the string 's' to the terminal, and reads a
		character in reply.

		If the character is 'y' or 'Y' TRUE is returned,
		otherwise FALSE is returned.

Suggestions for improvement:

		1. Instead of returning FALSE if an error occurs,
	           we could ask again until we get a correct response.

	        2. Rather than examining only the first character
		   read, we should skip all space characters until
		   we get something solid. If the line is empty,
		   ask again.

		3. Rather than testing for 'y' we should test for 'n'.
		   The reason is only that most languages use a
		   word that begins with 'n' for 'no', while very 
		   few languages use words beginning in 'y' for 'yes'.
		   Internationalization is the word! 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

static int ask(s)
char *s;
{
  char string[160];	/* input string */
  char c;		/* the response character */

  /*  1.  Print the string to standard output:  */

  printf(s);

  /*  2.  Read a string from standard input:  */

  if (fgets(string, sizeof(string), stdin) == 0) {	/* EOF or error */
    return FALSE;
  }

  /*  3.  Examine first character in string:  */

  c = toupper(string[0]);

  return (c == 'Y');
}

/*----------------------------------------------------------------------

Routine:	cats

Description:	This function returns true if all nine squares
		taken (usually called after checking for a win, so
		that all spaces filled indicates a cat's game)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

static int cats()
{
  int i;

  for (i=0; i<9; ++i) {
    if (board[i] == EMPTY) {
      return FALSE;
    }
  }

  return TRUE;
}

/*----------------------------------------------------------------------

Routine:	clear

Description:	Empty the board

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

static void clear()
{
  int i;

  for (i=0; i<9; ++i) {
    board[i] = EMPTY;
  }
}

/*----------------------------------------------------------------------

Routine:	display

Description:	Displays the playing board.

Note:		The original version of the routine accepted
		a parameter that indicated if the pieces should
		be displayed (the normal case), or if the
		square numbers (1-9) should be shown instead.

		The square numbers were only shown at the
		beginning of the game, and usually scrolled out of
		sight, making it difficult to remember them.

		This version prints the square number for empty
		squares and the piece for occupied squares.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

static void display()
{
  int r,c;	/* Not row and column, but almost ... */

  printf("\n\n");
  for (r=0; r<9; r+=3) {
    for (c=r; c< r+3; ++c) {
      putchar(' ');
      switch (board[c]) {
        default:
	  fprintf(stderr, "ttt(display): unknown piece (%d) on board (%d)",
			   board[c], c);
          exit(EXIT_FAILURE);

	case EMPTY:
	  printf("%1d", c+1);
	  break;

	case X:
	  putchar('X');
	  break;

	case O:
	  putchar('O');
	  break;
      }
      putchar(' ');
      if (c != r+2) {
        putchar('|');
      }
    }
    putchar('\n');
    if (r != 6) {
      printf("---+---+---\n");
    }
  }
  putchar('\n');
}

/*----------------------------------------------------------------------

Routine:	getmove

Description:	reads a string containing a digit, and returns
		the digit as result.

		If no digit could be read, -1 is returned.

Suggestions for improvement:

		See the description of ask() above!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

static int getmove()
{
  char string[160];	/* input string */

  /*  1.  Read a string from standard input:  */

  if (fgets(string, sizeof(string), stdin) == 0) {	/* EOF or error */
    return -1;
  }

  /*  2.  Return value of digit:  */

  return string[0] - '0';
}

/*----------------------------------------------------------------------

Routine:	main

Description:	main program

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

int main()
{
  int i;
  int mefirst;			/* 1: computer goes first; 0: human */
  int turn;			/* counts number of moves played */
  int finished;			/* true if game is over */
  int mypiece, hispiece;	/* who has x or o */
  int mywins, hiswins, catwins;	/* game count */
  int t;

  /*  1.  Initialize:  */

  srand(0);			/* initialize random generator */
  mywins = hiswins = catwins = 0;
  mefirst = TRUE;		/* let human go first (see 2a below) */

  printf("\n\nWelcome to BDS Tic Tac Toe!!\n");
  printf("(In this version, X always goes first.\n");

  /*  2.  Outer game loop:  */

  do {

    /*  2a.  Set up for new game:  */

    finished = FALSE;
    mefirst = !mefirst;		/* reverse who goes first */
    turn = 0;
    clear();			/* clear the game board */

    if (mefirst) {
      printf("I go first...\n");
      display();		
    } else {
      printf("You go first...\n");
    }
    mypiece = mefirst ? X : O; 	/* set who has got what */
    hispiece  = mefirst ? O : X;
    if (!mefirst) goto hismove;

    /*  2b.  Inner game loop:  */

    while (!finished) {

      /*  2c.  Computer's move:  */

      if (turn == 0) {	/* Random opening move */
        BEST = rand() % 9;
      }

      if (turn == 1) {	/* Response to player's opening move */   
        if (board[4] != EMPTY) {	/* Center is occupied */
          BEST = rand() % 2 * 6 +	rand() % 2 * 2;
        } else {			/* Grab center */
          BEST = 4;
        }
      }

      if (turn > 1) {	/* OK, we're into the game... */    
        t = ttteval(mypiece, hispiece);
        if (t == 1) printf("I've got ya!\n");
      }

      board[BEST] = mypiece;  	/* make the move */
      ++turn;

      printf("I move to %d\n", BEST+1);

      if (win(mypiece)) {
        ++mywins;
        printf("\nI win!!!\n");
        finished = TRUE;
      } else if (cats()) {
        ++catwins;
        printf("\nMeee-ow!\n");
        finished = TRUE;
      }

hismove:
      if (!finished) {

        /*  2b.  Player to move:  */
 
        display();

        do {
          printf("Your move (1-9) ? ");
          i = getmove();
          if (i < 1 || i > 9 || board[i-1]) {
            printf("\nIllegal!\n");
            i = 0;	/* indicates erroneous move */
          }
        } while (i == 0);

        board[i-1] = hispiece;
        ++turn;
        display();
        if (win(hispiece)) {
          ++hiswins;
          printf("\nYou beat me!!\n");
          finished = TRUE;
        } else if (cats()) {
          ++catwins;
          printf("\nOne for Morris.\n");
          finished = TRUE;
        }
      }

    }  /* Inner game loop */

  } while (ask("\nAnother game (y/n) ? "));

  /*  3.  Print final statistics:  */

  printf("\n\nOK...Final score:\n");
  printf("You won %d game", hiswins);
  if (hiswins != 1) putchar('s');

  printf(";\nI won %d game", mywins);
  if (mywins != 1) putchar('s');

  printf(";\nThe Cat got %d game",catwins);
  if (catwins != 1) putchar('s');

  printf(".\nSee ya later!!\n");

  return EXIT_SUCCESS;
}

/*----------------------------------------------------------------------

Routine:	ttteval

Description:	The function "ttteval" returns an evaluation of
		player x's position on the tic-tac-toe board. If he's
		in a winning position, 1 is returned. If the best he
		can hope for is a cat's game, 0 is returned. And, if
		he's sure to lose if player y plays correctly, -1 is
		returned. In any case, the best move available to 
		player x is left in external variable BEST upon return
		from ttteval.

		Note that a value of -1 is often returned while
		recursive searching branches down into all possible
		wins and losses, but with the program in the shape
		it appears here, the outermost-level call to ttteval
		(from the main program) will never produce a return
		value of -1, since the computer has decided not to be
		able to lose (the obviously logical choice of any
		self-respecting problem-solver.)

		In any case, the main program still bothers to 
		consider the possibility of losing, so that if you
		want to try inserting your own "ttteval" routine
		in place of the one given, it dosn't have to be
		perfect in order to work with the main program.
		Tic-tac-toe is, of course, just about the only game
		in which it is feasible to do an exhaustive search;
		most game evaluation algorithms only go so deep and
		then make a "static" evaluation, or estimate of the
		player's status at the terminal position. That is how
		all decent chess playing programs today work.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

static int ttteval(me, him)
int me;
int him;
{
  int i,safemove;
  int v,loseflag;
	
  /*  1.  Is game terminated?  */  

  if (win(me))  return 1;
  if (win(him)) return -1;
  if (cats())   return 0;

  /*  2.  Try out all moves and see what happens:  */

  loseflag = 1;
  for (i=0; i<9; ++i) {
    if (board[i] == EMPTY) {	/* a legal move */
      board[i] = me;		/* try the move...*/
      v = ttteval(him,me);	/* ...evaluate the resulting position */
      board[i] = EMPTY;		/* and undo the move */

      if (v == -1) { 		/* if we force a loss, yey! */
        BEST = i;
        return 1;
       }

      if (v) continue;   	/* uh oh! we shouldn't get beaten! */
      loseflag = 0;		/* cat's game guaranteed at least */
      safemove = i;
    }
  }
  BEST = safemove;
  return -loseflag;		/* if loseflag is true, this returns
				   -1 to indicate a loss; else zero
				   is returned (cat's game.)    */
}

/*----------------------------------------------------------------------

Routine:	win

Description:	returns true (non-zero) if player p has three in a row
		on the board:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

static int win(p)
int p;
{
  int i;
  for (i=0; i<8; ++i) {
    if (board[wins[i][0]] == p &&
        board[wins[i][1]] == p &&
        board[wins[i][2]] == p) return 1;
  }
  return 0;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩视频中午一区| 亚洲国产一区视频| 伊人性伊人情综合网| 天天色天天爱天天射综合| 国产传媒欧美日韩成人| 欧美三级视频在线| 中文天堂在线一区| 免费观看91视频大全| 91豆麻精品91久久久久久| 久久久久久久久久久久久女国产乱 | 中文字幕一区不卡| 久久精品国产一区二区三区免费看 | 综合色中文字幕| 蜜臀va亚洲va欧美va天堂| 日本精品一区二区三区四区的功能| 精品久久久久久亚洲综合网| 午夜a成v人精品| 91行情网站电视在线观看高清版| 国产喂奶挤奶一区二区三区| 美女视频一区二区| 欧美一区二区三区婷婷月色| 亚洲国产精品久久久久秋霞影院| 91亚洲精华国产精华精华液| 中文av一区特黄| 国产成人免费视频网站高清观看视频| 日韩精品一区二区三区swag| 日本在线观看不卡视频| 欧美日韩一级二级| 午夜视黄欧洲亚洲| 欧美日韩黄视频| 亚洲国产婷婷综合在线精品| 色噜噜狠狠成人网p站| 最新国产精品久久精品| 99久久久国产精品免费蜜臀| 国产精品久久二区二区| av不卡免费电影| 国产精品久久久久久久久搜平片| 高清不卡一二三区| 国产精品久久久久久久久快鸭| 成人精品视频.| 中文字幕一区二区三区蜜月| 91在线看国产| 亚洲精品乱码久久久久久黑人 | 中文字幕av在线一区二区三区| 成人午夜在线视频| 亚洲欧美日韩在线播放| 欧美中文字幕一二三区视频| 日韩精品欧美精品| 欧美不卡视频一区| 国产河南妇女毛片精品久久久 | 国产成人在线视频网址| 欧美激情一区三区| 99国产精品国产精品毛片| 亚洲视频在线一区| 欧美乱熟臀69xxxxxx| 老司机午夜精品99久久| 久久精品男人的天堂| 91在线视频官网| 亚洲一区二区三区视频在线| 日韩一级成人av| 盗摄精品av一区二区三区| 成人免费在线观看入口| 欧美日韩一区二区欧美激情| 精品一区二区影视| 亚洲男人的天堂在线观看| 欧美日韩日日骚| 国产精品自拍一区| 一区视频在线播放| 欧美一区二区视频在线观看| 国产一区在线观看视频| 亚洲精品乱码久久久久久久久| 日韩一级片在线播放| 91首页免费视频| 免费成人深夜小野草| 亚洲欧洲日韩av| 337p亚洲精品色噜噜噜| 成人动漫中文字幕| 日本在线不卡一区| 亚洲日本护士毛茸茸| 久久综合久久综合久久| 色婷婷综合激情| 国产真实乱子伦精品视频| 亚洲线精品一区二区三区八戒| 久久影院视频免费| 欧美精品久久99久久在免费线| 国产丶欧美丶日本不卡视频| 日本午夜一本久久久综合| 综合网在线视频| 欧美xxxxxxxxx| 欧美性xxxxx极品少妇| proumb性欧美在线观看| 精品一区二区成人精品| 亚洲图片一区二区| 亚洲同性gay激情无套| 欧美精品一区二区久久婷婷| 欧美丰满嫩嫩电影| 欧美性感一类影片在线播放| 91丨九色丨蝌蚪富婆spa| 国产精品1024| 激情综合五月天| 日韩电影在线一区| 亚洲一区在线观看视频| 亚洲人成网站精品片在线观看| 久久久蜜桃精品| 欧美不卡激情三级在线观看| 91精品午夜视频| 欧美日韩一级大片网址| 欧美在线视频全部完| 91丨国产丨九色丨pron| 99久久精品久久久久久清纯| 成a人片国产精品| 国产成人在线观看| 国产99一区视频免费| 国产很黄免费观看久久| 国产成人av电影在线播放| 精品在线一区二区| 国产激情精品久久久第一区二区| 国产精品一二三在| 国产精品一区免费视频| 国产+成+人+亚洲欧洲自线| 国产美女视频91| 丰满放荡岳乱妇91ww| 成人小视频免费观看| av网站一区二区三区| 91免费视频网| 色婷婷久久一区二区三区麻豆| 日本韩国一区二区| 欧美日本在线视频| 日韩一区二区三区电影| 精品乱人伦一区二区三区| wwwwww.欧美系列| 欧美激情综合五月色丁香| 亚洲欧美日韩国产另类专区 | 日本麻豆一区二区三区视频| 久久99热国产| 菠萝蜜视频在线观看一区| 色综合一个色综合亚洲| 欧美色图片你懂的| 欧美挠脚心视频网站| 日韩精品自拍偷拍| 中文字幕欧美激情一区| 一区二区三区四区在线免费观看| 亚洲国产精品嫩草影院| 韩国在线一区二区| 91视频免费播放| 欧美精选午夜久久久乱码6080| 精品欧美乱码久久久久久1区2区| 久久精品一区四区| 亚洲自拍偷拍欧美| 国模少妇一区二区三区| 91在线视频观看| 欧美成人a在线| 亚洲蜜臀av乱码久久精品| 久久国产三级精品| 色婷婷精品大视频在线蜜桃视频 | 91美女在线观看| 制服丝袜成人动漫| 欧美激情一区不卡| 日本在线不卡视频| 91色乱码一区二区三区| 日韩精品一区在线观看| 亚洲精品videosex极品| 另类中文字幕网| 色婷婷综合在线| 国产欧美一区二区精品秋霞影院| 亚洲成人资源网| 播五月开心婷婷综合| 26uuu精品一区二区| 亚洲高清视频中文字幕| 成人午夜电影网站| 欧美哺乳videos| 亚洲电影一区二区三区| 91在线国产观看| 国产亚洲精品免费| 久久99精品一区二区三区三区| 色播五月激情综合网| 国产精品午夜免费| 国模少妇一区二区三区| 欧美一区二区视频在线观看| 一区二区三区高清不卡| 99热99精品| 亚洲国产精品99久久久久久久久| 精品一区二区三区久久| 欧美一级黄色录像| 香蕉乱码成人久久天堂爱免费| 91女神在线视频| 中文字幕中文字幕在线一区| 国v精品久久久网| 欧美一级二级三级蜜桃| 日韩av在线播放中文字幕| 欧美日韩高清影院| 亚洲一区av在线| 在线免费亚洲电影| 亚洲在线视频一区| 91久久精品一区二区二区| 中文字幕日韩av资源站| heyzo一本久久综合| 国产精品超碰97尤物18| 丰满少妇在线播放bd日韩电影| 久久久久久久久久久电影|