/* Programa acerte o numero */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define T_VETOR 10
int main(void)
{
unsigned short vetor[T_VETOR], cont;
/* Inicia o vetor */
for (cont = 0; cont < T_VETOR; cont++) {
vetor[cont] = cont+1;
}
srand(time(NULL));
/* Embaralha os numeros */
for (cont = 0; cont < T_VETOR; cont++) {
unsigned short tmp = vetor[cont], indice = rand()%T_VETOR;
vetor[cont] = vetor[indice];
vetor[indice] = tmp;
}
printf("\nDigite um numero entre 1 a 10:\t");
scanf("%hu%*c", &cont);
printf("\nO numero e %hu", vetor[0]);
if (vetor[0] == cont) {
printf("\nVoce acertou!");
} else {
printf("\nVoce errou!\nBoa sorte na proxima vez");
}
getchar(); /* pausa */
return(0);
}