惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

博客园 - 段静迪

跟我学LINQ之一:为什么要学习LINQ JAVA猜字游戏 在.NET平台下实现打印超市收银票据 JAVA上课源代码 基于三层架构的软件开发技术 MS-SQL数据库开发常用汇总 计算机类在Java中的设计于实现码 基于C语言的个人所得税计税系统 JAVA 教学实例 在.NET平台下使用SQL2000 Image类型数据 在.NET平台下使用SQL2000 Image类型数据 对SQL Server2000数据块进行查询 界面和业务代码分离的记事本 在.Net平台下读写文件流 键盘游戏 多线程摇奖机程序源代码 网页第五章 HTML标签详解 JDK 目录下的*.exe文件的使用
C语言游戏
段静迪 · 2007-11-16 · via 博客园 - 段静迪
 

C言游

除代码外均由李明女完成,本程序只是部分基本功能

名称猜数字

使用C

规则电脑随机生成一个1-30的数字,人和电脑猜一个数字,的数字较为接近生       成的数字.

要求人和电脑各有10000,玩家多少分,分数上限500,非正常分数,提示错误      并要求重新,直到入正确范围为.运行游和一局完了的候要示游.

内容有

    帮助明游戏规则.

    始游入游.

    查询记录查询程序始到在的输赢记录.记录最多50,便将上面的分数.             记录的内容有电脑生成的数,玩家和电脑猜的数,以及.

    退出游束程序.

一局完了,,都要出相的激励或鼓励的,,出的不少于4,随机.

例如

第一局,:太棒了,!

第二局,:太好了,你怎做到的!

的情况也.

当一方分数小于等于0,判定一方.

当在菜9999,启无模式,即无猜都是玩家.

1、产生随机数的方法:

本函数用来取得随机数。本函数会自的从 0 RAND_MAX-1中取一个随机数。得注意的是使随机数的乱度最大,次在取随机数之前最好使用 srand() 以配置新的随机数 

#include   <stdio.h>  

  #include   <stdlib.h>  

  #include   <time.h>  

   
  /*
要用到上面几个.h文件。*/  

  int   i;  

  time_t   t;  

   
  srand((unsigned)   time(&t));  

  i=rand() % 500; //0~500 

2fflush(stdin)

fflush(stdin)刷新冲区,把冲区里的西

函数名: fflush

功 能: 清除一个流

用 法: int fflush(FILE *stream);

#include <stdio.h>
int main()

{     int a;

    char c;

    do
    {
        scanf("%d",&a);

        fflush(stdin);

        scanf("%c",&c);

        fflush(stdin);

        printf("a=%d     c=%c"n",a,c);

    }while(c!='N');

}     

system("cls");

system("cls");的意思就是DOS下的清屏命令“cls”

源代码:

#include <stdio.h>

 #include   <time.h>  

void main()

{

 int i,j;

 int times =0;

 char ch;

 do

 {

 srand((int)time(0));

 for(i=0;i<10;i++)

 {

       j=1+(int)(10.0*rand()/(20+1.0));

       printf(" %d ",j);

 }

 i=100 + j%201;

 do

 {

       printf("输入一个100~300的数%d",i);

       scanf("%d",&j);

       if(i > j)

       {

             printf("过小"n");

       }

       else     if(i < j)

       {

                  printf("过大"n");

       }

       else

       {

                  printf("答对了"n");

                        break;

       }

       times++;

       if(times > 50)

       {

             printf("你太笨了,不要再猜了"n");

                  break;

       }

 }while(1);

       printf("你还继续猜吗?");

       fflush(stdin);

       scanf("%c",&ch);

 }while ((ch == 'Y' )||( ch== 'y'));

 //printf("%d",i);

}