6 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <stdlib.h>
int main( void ) {
int i;
srand( time(NULL));
for(i=0; i <= 10; i++)
printf("%d\n", rand());
return(1);
}
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, const char *argv[]) {
int i;
srand( clock() );
for(i=0; i <= 10; i++)
printf("%d\n", rand());
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/timeb.h>
int main(int argc, const char *argv[]) {
int i;
unsigned int ts;
struct _timeb timebuffer;
_ftime( &timebuffer );
memcpy(&ts, &timebuffer, sizeof(unsigned int));
srand( ts );
for(i=0; i <= 10; i++)
printf("%d\n", rand());
return 0;
}
1
2
3
rootcris@J-jayz-Z:~/C$ gcc -o zufall zufall.c
zufall.c: In Funktion »main«:
zufall.c:9: error: storage size of `timebuffer' isn't known
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/timeb.h>
int main(int argc, const char *argv[]) {
int i;
unsigned int ts;
struct _timeb timebuffer;
_ftime( &timebuffer );
ts = timebuffer.time * 1000 + timebuffer.millitm;
srand( ts );
for(i=0; i <= 10; i++)
printf("%d\n", rand());
return 0;
}
6 Einträge, 1 Seite |