Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- int main() {
- int numero, x;
- int tentativas = 1;
- char s = 't';
- srand(time(NULL));
- x = rand() % 100 + 1;
- printf("Advinhe o número de 0 a 100\n\n");
- do {
- printf("\nDigite um número: ");
- scanf("%d", &numero);
- if (numero > x) {
- printf("O número certo é menor do que a tentativa feita");
- }
- else {
- if (numero < x)
- printf("O número certo é maior do que a tentativa feita");
- else {
- printf("\nVocê acertou o número");
- printf("\nNúmero de tentativas: %d", &tentativas);
- printf("\n %d é o número certo", x);
- }
- }
- /* tentativas++;
- } while (num != x && tentativas <= 20);
- if (tentativas > 20) {
- printf("\n\nVOCÊ ULTRAPASSOU O LIMITE DE TENTATIVAS! TENTE OUTRA VEZ!");
- printf("\nO número era: %d", x);
- }
- */
- while (s != 's' && s != 'n') {
- printf("\n\nDeseja tentar novamente? [s/n]: ");
- scanf("%c", &s);
- if (s == 's')
- main();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment