-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasicas.cpp
78 lines (62 loc) · 1.3 KB
/
basicas.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
#define MAX 20
#define LIM 50
// operacions basicas de datos simples
int leeEntero(char msje[], int min, int max,char msje1[])
{
int num,flag;
do
{
printf("%s", msje);
scanf("%d", &num);
if(num<=min && num>=max)
{
printf("%s", msje1);
}
}while(!(num>=min && num<=max));
return num;
}
float leeReal(char msje[], float min, float max)
{
float num;
do
{
printf("%s", msje);
scanf("%f", &num);
}while(!(num>=min && num<=max));
return num;
}
//Adicionales
char leeSexo(char msje[])
{
char rpta;
cout << " F : Femenino" <<endl;
cout << " M : Masculinoino" <<endl;
do
{
printf("%s", msje);
fflush(stdin);
scanf("%c",&rpta);
rpta= toupper(rpta);
}while(!(rpta=='F' || rpta== 'M'));
return rpta;
}
char leeCaracter(char msje1[],char msje2[],char A,char B,char msje[])
{
char rpta;
cout << msje1 <<endl;
cout << msje2 <<endl;
do
{
printf("%s", msje);
fflush(stdin);
scanf("%c",&rpta);
rpta= toupper(rpta);
}while(!(rpta==A || rpta== B));
return rpta;
}