X-Git-Url: https://git.harvie.cz/?a=blobdiff_plain;f=c%2Frand.c;fp=c%2Frand.c;h=0c068460304683c1782aa1554ad6e936958c3c9c;hb=79a323cb54e2b2b1b67aa7492b25fb44036e7007;hp=0000000000000000000000000000000000000000;hpb=498f46739bc749de52a989e06c77317260e30ad0;p=mirrors%2FPrograms.git diff --git a/c/rand.c b/c/rand.c new file mode 100644 index 0000000..0c06846 --- /dev/null +++ b/c/rand.c @@ -0,0 +1,23 @@ +#include +#include +#include + +int main() { + int g, r, max = 10; + char buff[80]; + while(1) { + r = rand() % max; + printf("hadej cislo (od 0 do" + "%d):", max - 1); + fgets(buff, sizeof(buff)-2, stdin); + *strpbrk(buff, "\r\n") = '\0'; + if (!*buff) + break; + g = strtol(buff, NULL, 10); + if(r == g) puts("Bravo maestro!"); + else printf("Loooooooozre! " + "bylo to %d\n", r); + + } + puts("konec!"); +}