forked from MaterialesProgramacion/ProblemasProgramacion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adivinarNumero.c
45 lines (39 loc) · 822 Bytes
/
adivinarNumero.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* @authors Equipo docente programacion grado de ingenieria
* @university UAL
* @date 2019-02-06
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <math.h>
int main(){
char c;
int n,r;
do{ system("cls");
printf("ADIVINAR NUMERO DE UN DIGITO\n");
printf("============================\n\n");
do{ printf("Introduzca P (par) o I (impar): ");
c=toupper(getche());
printf("\n");
}while((c!='P')&&(c!='I'));
do{ printf("Introduzca resto de division entre 5: ");
scanf(" %d", &r);
}while((r<0)||(r>=5));
if(c=='P')
if(r%2)
n=r+5;
else
n=r;
else
if(r%2)
n=r;
else
n=r+5;
printf("\nEl numero es: %d", n);
printf("\n\nDesea efectuar una nueva operacion (s/n)? ");
c=toupper(getch());
}while (c!='N');
return 0;
}