#include <stdio.h>
#include <stdlib.h>
int main(void) {
int x[8];
printf("Gerando 10 valores aleatorios:\n"); for (int i = 0; i < 8; i++) {
if (x[i] == 3) {
int sorteado = -1;
while ((sorteado
= rand() % 8) != i
); //repete até achar um valor aceitável x[i] = sorteado;
} else {
}
printf("[%d] = %d\n", i
, x
[i
]); }
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKHZvaWQpIHsKICAgIGludCB4WzhdOwogICAgcHJpbnRmKCJHZXJhbmRvIDEwIHZhbG9yZXMgYWxlYXRvcmlvczpcbiIpOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCA4OyBpKyspIHsKICAgICAgICBzY2FuZigiJWQiLCAmeFtpXSk7CiAgICAgICAgaWYgKHhbaV0gPT0gMykgewogICAgICAgIAlpbnQgc29ydGVhZG8gPSAtMTsKICAgICAgICAJd2hpbGUgKChzb3J0ZWFkbyA9IHJhbmQoKSAlIDgpICE9IGkpOyAvL3JlcGV0ZSBhdMOpIGFjaGFyIHVtIHZhbG9yIGFjZWl0w6F2ZWwKICAgICAgICAgICAgeFtpXSA9IHNvcnRlYWRvOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgCXhbaV0gPSByYW5kKCkgJSA4OwogICAgICAgIH0KICAgICAgICBwcmludGYoIlslZF0gPSAlZFxuIiwgaSwgeFtpXSk7CiAgICB9Cn0=