Last active
April 6, 2018 03:08
-
-
Save samirfor/fb42fe9e9e0ca2b02de17b8491e1cd92 to your computer and use it in GitHub Desktop.
Gera 3 números distintos inteiros pares múltiplos de 3, entre 1 e 35.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
int gerar() | |
{ | |
int r = ((rand() % (35 / 2)) + 1) * 2; | |
while (r % 3) | |
{ | |
r = ((rand() % (35 / 2)) + 1) * 2; | |
} | |
return r; | |
} | |
int main() | |
{ | |
srand(time(NULL)); | |
int m = gerar(); | |
int n = gerar(); | |
int p = gerar(); | |
while (n == m) | |
{ | |
n = gerar(); | |
} | |
while (p == n || p == m) | |
{ | |
n = gerar(); | |
} | |
printf("%d %d %d", m, n, p); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment