Folgend finden Ihr einen Zufallsgenerator der entweder Kopf oder Zahl auswirft.
Quellcode[]
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
- int zufall;
- int zeit;
- int wert;
- int zufall;
- zeit = time(0);
- srand(zeit);
- zeit = time(0);
- zufall = rand (),
- wert = zufall % 2;
- if (wert == 0 ) printf("Sie haben Kopf geworfen!\n");
- else printf("Sie haben Zahl geworfen!\n");
- zufall = rand (),
}