-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathherramientas.cpp
50 lines (32 loc) · 1.09 KB
/
herramientas.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
#include <iostream>
#include "herramientas.h"
// ------------------------------------------------------------------------------------------------------------
bool contiene_numeros(string s){
const string CONT = "0123456789";
if(s.find_first_of(CONT) != string::npos){
return true;
}else
return false;
}
// ------------------------------------------------------------------------------------------------------------
bool contiene_letras(string s){
const string CONT = "0123456789";
if(s.find_first_not_of(CONT) != string::npos){
return true;
}else
return false;
}
// ------------------------------------------------------------------------------------------------------------
bool es_un_numero(string str)
{
char c;
int N = (int) str.length();
bool validez = true;
if(!N) // string vacia
validez = false; // si N == 0 ni va a entrar al for()
for (int i = 0 ; i < N ; i++) {
c = str[i];
if (isdigit(c) == 0) validez = false;
}
return validez;
}