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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - 段静迪

跟我学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);

}