啊哈磊_编程从这里起步

标题: 会变化的程序 [打印本页]

作者: 13410046343    时间: 2012-9-15 14:36
标题: 会变化的程序
每次启动程序,程序发生了变化

未命名.jpg (81.9 KB, 下载次数: 40)

未命名.jpg

计算器.rar

4.73 KB, 下载次数: 94


作者: 花落无痕    时间: 2012-9-15 15:35
哇~这是什么原理呢?
作者: wsy2012007    时间: 2012-9-16 20:45
随机数




作者: Nurahmat    时间: 2012-9-25 23:45
源代码可以发给我吗?
357710085@qq.com
谢谢!
作者: 啊哈磊    时间: 2012-9-26 10:16
不错不错
作者: missyangxing    时间: 2012-10-17 12:55
怎么搞的呢
作者: zjfa    时间: 2012-10-17 21:41
看下是什么
作者: ztcwlj    时间: 2012-10-18 11:10
看看什么情况!
作者: 梦中的婚礼    时间: 2012-10-18 19:40
看看~..
作者: 梦中的婚礼    时间: 2012-10-20 21:54
本帖最后由 梦中的婚礼 于 2012-10-20 22:02 编辑

为了方便,
用了很多的无用头文件。。。
其实这是调用了随机的函数。。
大家试试下面这段代码:
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#include <malloc.h>
#include <dos.h>
#include <time.h>
#include <ctype.h>
main()
{
int b;
srand( (unsigned)time( NULL ) );
b=rand()%3+1;
    {
  if(b==1)
   {
    system("color c5");
                                printf("红色");
               
               
                        }
  if(b==2)
   {
    system("color e6");
                                printf("黄色");
               
                        }
  if(b==3)
   {
    system("color d5");
                                printf("紫色");
               
                        }
    }
    getch();
    return 0;
           
}

我不知道到底是不是这种原理。。

作者: yzb849097193    时间: 2012-10-20 22:39
000000000000000000000000000
作者: piaoxu    时间: 2012-10-26 13:48
这么做的这个
作者: asp1024    时间: 2012-10-27 09:58
我觉得我没前途啊
作者: qazplm138141    时间: 2013-1-4 07:09
简化一下
#include <stdio.h>
main()
{
        int b;
        srand((unsigned)time( NULL ));
        b=rand()%4;
    printf("%d",b);
     {
      if(b==1){system("color c5");}
      if(b==2){system("color e6");}
      if(b==3){system("color d5");}
     }
    sleep(2000);
    return 0;
           
}
作者: qazplm138141    时间: 2013-1-4 07:13
再发个带注释的(我真蛋疼)
#include <stdio.h>//头文件stdio.h
main()//主程序
{
        int b;//创建变量b
        srand((unsigned)time( NULL ));//初始化随机数种子(随机数其实是由随机数种子计算出来的)
        b=rand()%4;//取随机数并且赋值给b,值位于1~4之间
    printf("%d",b);//输出b的值
     {
      if(b==1){system("color c5");}//如果b值为1,那么执行system("color c5")
      if(b==2){system("color e6");}//同上
      if(b==3){system("color d5");}//同上
     }
    sleep(2000);//等待两秒
    return 0;//返回0
           
}
作者: c-小巍    时间: 2013-1-25 13:53
{:soso_e113:}是的
作者: 4k-Rn    时间: 2013-3-12 21:01
梦中的婚礼 发表于 2012-10-20 21:54
为了方便,
用了很多的无用头文件。。。
其实这是调用了随机的函数。。

是。。。
伪随机数




欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/) Powered by Discuz! X3.2