-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrand_matrix.c
More file actions
47 lines (42 loc) · 715 Bytes
/
Copy pathrand_matrix.c
File metadata and controls
47 lines (42 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Name: rand_matrix.c
* Desc: print rand number in console or tty
* Usage: gcc rand_matrix.c -o rand_matrix
* Author: zuohaitao
* Date: 2009-03-07
*/
#ifdef WIN32
#include <windows.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main()
{
int nRand;
int i;
#ifdef WIN32
HANDLE hStdout;
#endif
srand( (unsigned)time( NULL ) );
while(1)
{
for (i = 0; i < 16 * 10; i++)
{
nRand = rand();
#ifdef WIN32
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN);
printf("%04x ", nRand);
#else
printf("\33[32m%08x \33[40;37m", nRand);
if (0 == i%5)
{
printf("\n");
}
#endif
}
//_sleep(100);
}
return 0;
}