Zufallszahl zwischen 1 und 180

Post Reply
Message
Author
Labba

Zufallszahl zwischen 1 und 180

#1 Post by Labba »

Mit welcher Funktion kann ich eine ( ganzzahlige ) Zufallszahl zwischen 1 und 180 bestimmen ?
Wie muss ich sie intialisieren ?

Jochen

Re: Zufallszahl zwischen 1 und 180

#2 Post by Jochen »

man 2 time
man 3 srand
man 3 rand
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main (int argc, char **argv)
{
srand(time(NULL));
printf ("%d
",rand()%180+1);
} </font><hr></pre></blockquote>
Der Compiler schluckt den Code so. Viel Spass!

Labba

Re: Zufallszahl zwischen 1 und 180

#3 Post by Labba »

Vielen Dank !

Post Reply