Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h> //GENERARA NUMEROS
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <string>
- #include <cstdlib>
- #include <cstring>
- using namespace std;
- // 01 /////////////////////////////////////////////////////////////////////////
- int takeInt(string mensaje){
- int entero;
- do{
- cout<<mensaje;
- cin>>entero;
- if(cin.fail()==true){
- cin.clear();
- cin.ignore(100,'\n');
- cout<<"\n\t #ERROR: INGRESE UN NUMERO ENTERO\n\n"<<endl;
- continue;
- }
- else{break;}
- }while(true);
- return entero; }
- // 02 /////////////////////////////////////////////////////////////////////////
- double takeDouble(string mensaje){
- double numero;
- do{
- cout<<mensaje;
- cin>>numero;
- if(cin.fail()==true){
- cin.clear();
- cin.ignore(100,'\n');
- cout<<"\n\t #ERRO: INGRESE UN NUMERO\n\n";
- continue;
- }
- else{break;}
- }while(true);
- return numero; }
- // 03 /////////////////////////////////////////////////////////////////////////
- float takeFloat(string mensaje){
- float numero;
- do{
- cout<<mensaje;
- cin>>numero;
- if(cin.fail() == true){
- cin.clear();
- cin.ignore(100,'\n');
- cout<<"\n\t - ERROR CARGUE "<< mensaje <<"\n\n";
- continue;
- }
- else{break;}
- }while(true);
- return numero; }
- // 04 /////////////////////////////////////////////////////////////////////////
- int takeOption(string mensaje, int desde, int hasta){
- int option;
- do{
- cout<<mensaje;
- cin>>option;
- if(cin.fail()==true||option<desde||option>hasta){
- cin.clear();
- cin.ignore(100,'\n');
- cout<<"\t # ERROR: OPCION NO EXISTE.\n"<<endl;
- continue;
- }
- else{break;}
- }while(true);
- return option; }
- // 05 /////////////////////////////////////////////////////////////////////////
- char validarRespuesta(string mensaje, char respuesta){
- do{
- if(respuesta== 'S'||respuesta == 's'||respuesta=='n'||respuesta=='N'){
- return respuesta;
- }
- else{ fflush(stdin);//LIMPIA EL BUFFER
- cout<<mensaje;
- cin>>respuesta;
- }
- }while(1);
- }
- // 06 /////////////////////////////////////////////////////////////////////////
- void int_Cadena(int numero, char cadena[]){
- //convierte un int a cadena
- int digitos = 0;
- int auxiliar = numero;
- int dig;
- while(auxiliar>0){
- auxiliar = auxiliar/10;
- digitos++;
- }
- cadena[digitos]='\0';
- auxiliar = numero;
- int posicion = digitos-1;
- while(posicion>=0){
- dig = auxiliar%10;
- auxiliar = auxiliar/10;
- cadena[posicion]= dig + '0';
- posicion--;
- }
- }
- // 07 /////////////////////////////////////////////////////////////////////////
- void saltoDeLinea(){
- cout<<"\n\n";
- }
- // 08 /////////////////////////////////////////////////////////////////////////
- void listaVacia(string tipo){
- cout<<"\n\t - LISTA DE "<<tipo<<" -> SIN ELEMENTOS.";
- saltoDeLinea();
- }
- // 09 /////////////////////////////////////////////////////////////////////////
- void takeChar(string mensaje, int demencion, char cadena[]){
- char texto[demencion] = "\0";
- do{
- cout<<mensaje;
- cin.getline(texto,30,'\n');
- if(cin.fail() == true){
- cin.clear();
- cin.ignore(100,'\n');
- cout<<"\n\t - ERROR EN LA CARGA. \n\n";
- continue;
- }
- else{break;}
- }while(true);
- }
- // 10 /////////////////////////////////////////////////////////////////////////
- long int takeLongInt(string mensaje){
- long int entero;
- do{
- cout<<mensaje;
- cin>>entero;
- if(cin.fail()==true){
- cin.clear();
- cin.ignore(100,'\n');
- cout<<"\n\t # ERROR: INGRESE NUMEROS. \n\n"<<endl;
- continue;
- }
- else{break;}
- }while(true);
- return entero; }
- // 11 /////////////////////////////////////////////////////////////////////////
- using std::cout; using std::endl;
- using std::cin; using std::string;
- //---------------------------------------------------------------------------//
- /* void validarDNI(){
- int dni,longitud;
- char dniCadena[] = "vacio";
- do{
- dni = takeInt("\t > INGRESE DNI:");
- int_Cadena(dni,dniCadena);
- longitud = strlen(dniCadena);
- if( longitud == 7 ||longitud == 8 ){
- auto dniCadena = std::strtol(dniCadena.data(), nullptr, 10);
- printf("%ld", dniCadena);
- break;
- }
- else{
- cout<<" # ERROR: VERIFIQUE BIEN LOS DIGITOS DE SU DNI.\n";
- }
- }while(true);
- cout<<"\n - DNI: "<<dniCadena;
- }*/
- // 12 /////////////////////////////////////////////////////////////////////////
- // 13 /////////////////////////////////////////////////////////////////////////
- // 14 /////////////////////////////////////////////////////////////////////////
- // 15 /////////////////////////////////////////////////////////////////////////
- // 16 /////////////////////////////////////////////////////////////////////////
- // 17 /////////////////////////////////////////////////////////////////////////
- // 18 /////////////////////////////////////////////////////////////////////////
- // 19 /////////////////////////////////////////////////////////////////////////
- // 20 /////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment