Skip to content

Instantly share code, notes, and snippets.

@samirfor
Last active April 6, 2018 03:08
Show Gist options
  • Save samirfor/fb42fe9e9e0ca2b02de17b8491e1cd92 to your computer and use it in GitHub Desktop.
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.
#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