#include <stdlib.h>
#include <stdio.h>
#include <time.h>void main( void )
{
int i; /* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) ); /* Display 10 numbers. */
for( i = 0; i < 10;i++ )
printf( " %6d\n", rand() );
}
再转化一下吧,这样好像是在-32768----32767之间的。
#include <stdio.h>
#include <time.h>void main( void )
{
int i; /* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) ); /* Display 10 numbers. */
for( i = 0; i < 10;i++ )
printf( " %6d\n", rand() );
}
再转化一下吧,这样好像是在-32768----32767之间的。
解决方案 »
- 关于windows API打开文件对话框后获取文件名的问题
- OpenGL
- VC操作Excel数据库怎么获得一个xls文件的表单名?有没有好的Excel封装类?
- 请问大家一个在指定窗口绘画的问题
- 两个基础入门问题,好人给我详细解答!!
- 請問怎樣在窗口的任意位置顯示菜單呢,(不是電擊鼠標右鍵而彈出的那種)
- VC程序,访问远程主机上的SQL SERVER 2000 需要注意的几个要点和步骤
- 求一个POINT pts[8]画俩个竖着的tab的函数
- windows下如何获取键盘硬件扫描码(hardware scancode)
- 菜鸟送分:CEdit
- 请帮忙啊!我需要smtp协议的内容啊!
- 求最简单的SMTP发信源代码(100分)
srand(GetTickCount());
//**从a[5]中随机选一个数至b
int b=a[(rand()%5)];
//**再生成一个0至10^8之间(8位)的一个随机数c;
int c=rand()%100000000;
//**d=b*10^8+c
int d=b*100000000+c;