本帖最后由 梦中的婚礼 于 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;
}
我不知道到底是不是这种原理。。 |