设为首页 加入收藏

TOP

C++ 如何使用时间函数(一)
2013-02-08 14:30:55 】 浏览:1006
Tags:  如何 使用 时间 函数

  这里提供一个 记忆游戏 类似于记单词

  #include <stdio.h>                     /* For input and output   */

  #include <ctype.h>                     /* For toupper() function */

  //#include <stdbool.h>                   /* For bool, true, false  */

  #include <stdlib.h>                    /* For rand() and srand() */

  #include <time.h>                      /* For time() and clock() */

  int main(void)

  {

  /* Records if another game is to be played */

  char another_game = 'Y';

  /* true if correct sequence entered, false otherwise */

  int correct = false;

  /* Number of sequences entered successfully          */

  int counter = 0;

  int sequence_length = 0;     /* Number of digits in a sequence        */

  time_t seed = 0;             /* Seed value for random number sequence */

  int number = 0;              /* Stores an input digit                 */

  time_t now = 0;            /* Stores current time - seed for random values  */

  int time_taken = 0;        /* Time taken for game in seconds                */

  /* Describe how the game is played */

  printf("\nTo play Simple Simon, ");

  printf("watch the screen for a sequence of digits.");

  printf("\nWatch carefully, as the digits are only displayed"

  " for a second! ");

  printf("\nThe computer will remove them, and then prompt you ");

  printf("to enter the same sequence.");

  printf("\nWhen you do, you must put spaces between the digits. \n");

  printf("\nGood Luck!\nPress Enter to play\n");

  scanf("%c", &another_game);

  /* One outer loop iteration is one game */

   

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C/C++ 数组的初始化 下一篇二维数组的建立与文件操作

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目