Mit welcher Funktion kann ich eine ( ganzzahlige ) Zufallszahl zwischen 1 und 180 bestimmen ?
Wie muss ich sie intialisieren ?
Zufallszahl zwischen 1 und 180
Re: Zufallszahl zwischen 1 und 180
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!
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!