home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_100
/
155_01
/
rand.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-09
|
796b
|
38 lines
/*
* ùÉÉöé╔éµéΦéSîàé╠âeâXâgâfü[â^é≡ì∞ɼé╖éΘ
* ì∞ɼüFû{è╘
* 1990/10/01
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#define RANDOM(x) (rand()%(x)) /* 0-(x-1) é≡É╢ɼé╖éΘâ}âNâì */
#define MAX_NUMBER 2000 /* ùÉÉöÉ╢ɼÉö ü@ü@ü@ü@ */
char *zero[] = { /* 0 é≡ûäé▀éΘâeü[âuâï */
"000",
"00",
"0"
};
void main()
{
int i, length;
char char_rand[5], put[5];
srand((unsigned int)time(NULL));
for(i=1; i <= MAX_NUMBER; i++){
itoa(RANDOM(9999), char_rand, 10); /* ö±é`éméréhî▌è╖ü@*/
length = strlen(char_rand);
if(length < 4) {
strcpy(put, zero[length-1]);
strcat(put, char_rand);
}
else strcpy(put, char_rand);
printf("%s\n",put);
}
}