Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ejercicio 5.2
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- const int cantidadMaxima = 500;
- const int mayoresQue = 100;
- const int menoresQue = -10;
- enum formato {
- Y = 1,
- D = 2,
- M = 3
- };
- int yyyymmdd(int bb, int aa);
- int main()
- {
- /*
- string meses[]
- {
- enero
- febrero
- marzo
- abril
- mayo
- junio
- julio
- agosto
- septiembre
- octubre
- noviembre
- diciembre
- }
- */
- int numeritoMagico = 0;
- cout << "ingrese una fecha en formato YYYYMMDD: " << endl;
- cin >> numeritoMagico;
- cout << yyyymmdd(numeritoMagico, Y) << " ";
- if (yyyymmdd(numeritoMagico, M) < 10)
- {
- cout << "0";
- }
- cout << yyyymmdd(numeritoMagico, M) << " " << yyyymmdd(numeritoMagico, D);
- }
- int yyyymmdd(int bb, int aa)
- {
- int exportAnio = 0;
- int exportMes = 0;
- int exportDia = 0;
- switch (aa)
- {
- case Y:
- {
- exportAnio = bb / 10000;
- return exportAnio;
- }; break;
- case M:
- {
- exportMes = (bb - ((bb / 10000) * 10000)) / 100;
- return exportMes;
- }; break;
- case D:
- {
- exportDia = bb - ((bb / 10000) * 10000) - ((bb - ((bb / 10000) * 10000)) / 100) * 100;
- return exportDia;
- }; break;
- default:
- break;
- }
- }
- /*
- // ejercicio 5.1
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- const int cantidadMaxima = 500;
- const int mayoresQue = 100;
- const int menoresQue = -10;
- enum formato {
- Y = 1,
- D = 2,
- M = 3
- };
- int yyyymmdd(int bb, int aa);
- int main()
- {
- int numeritoMagico = 0;
- cout << "ingrese una fecha en formato YYYYMMDD: " << endl;
- cin >> numeritoMagico;
- cout << yyyymmdd(numeritoMagico, Y) << " ";
- if (yyyymmdd(numeritoMagico, M) < 10)
- {
- cout << "0";
- }
- cout << yyyymmdd(numeritoMagico, M) << " " << yyyymmdd(numeritoMagico, D);
- }
- int yyyymmdd(int bb, int aa)
- {
- int exportAnio = 0;
- int exportMes = 0;
- int exportDia = 0;
- switch (aa)
- {
- case Y:
- {
- exportAnio = bb / 10000;
- return exportAnio;
- }; break;
- case M:
- {
- exportMes = (bb - ((bb / 10000) * 10000)) / 100;
- return exportMes;
- }; break;
- case D:
- {
- exportDia = bb - ((bb / 10000) * 10000) - ((bb - ((bb / 10000) * 10000)) / 100) * 100;
- return exportDia;
- }; break;
- default:
- break;
- }
- }
- */
- /*
- // ejercicio 5
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- const int cantidadMaxima = 500;
- const int mayoresQue = 100;
- const int menoresQue = -10;
- int main()
- {
- int recorteAnio = 0;
- int recorteMes = 0;
- int recorteDia = 0;
- float recorteMesFloat = 0;
- int numeritoMagico = 0;
- int numeroQueEsMultiploDe3 = 0;
- int numeroQueNoEsMultiploDe5ySiDe3 = 0;
- int temp = 0;
- int contador = 0;
- cout << "ingrese una fecha en formato YYYYMMDD: " << endl;
- cin >> numeritoMagico;
- recorteAnio = numeritoMagico / 10000;
- recorteMes = (numeritoMagico - (recorteAnio * 10000))/100;
- recorteDia = numeritoMagico - (recorteAnio * 10000) - recorteMes * 100;
- cout << recorteDia << " " << recorteMes << " " << recorteAnio;
- }
- void YYYYMMDD(int bb, int aa)
- {
- int exportAnio = 0;
- int exportMes = 0;
- int exportDia = 0;
- switch (aa)
- {
- case y
- {
- exportAnio = bb / 10000;
- return exportAnio;
- }
- case m
- {
- exportMes = (bb - ((bb / 10000) * 10000)) / 100;
- return exportMes;
- }
- case d
- {
- exportDia = bb - ((bb / 10000) * 10000) - ((bb - ((bb / 10000) * 10000)) / 100) * 100;
- return exportDia;
- }
- default:
- break;
- }
- recorteAnio = numeritoMagico / 10000;
- recorteMes = (numeritoMagico - (recorteAnio * 10000)) / 100;
- recorteDia = numeritoMagico - (recorteAnio * 10000) - recorteMes * 100;
- }
- */
- /*
- // ejercicio 4
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- const int cantidadMaxima = 500;
- const int mayoresQue = 100;
- const int menoresQue = -10;
- int main()
- {
- int numeritoMagico = 0;
- int numeroQueEsMultiploDe3 = 0;
- int numeroQueNoEsMultiploDe5ySiDe3 = 0;
- int temp = 0;
- int contador = 0;
- cout << "Decime un numero: " << endl;
- cin >> numeritoMagico;
- while(contador < numeritoMagico)
- {
- temp =temp +3;
- if ( (temp % 5) != 0)
- {
- cout << " " << temp << " es divisible por 3 y no por 5" << endl;
- contador++;
- }
- }
- }
- */
- /*
- //EJERCICIO 3.1
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- const int cantidadMaxima = 500;
- const int mayoresQue = 100;
- const int menoresQue = -10;
- int main()
- {
- int numerosIngresados[cantidadMaxima];
- int index = 0;
- int valorMaximo = 0;
- int valorPuntero = 0;
- do
- {
- cout << "Ingresa un numero: ";
- cin >> numerosIngresados[index];
- if (numerosIngresados[index] > valorMaximo)
- {
- valorMaximo = numerosIngresados[index];
- valorPuntero = index;
- }
- index++;
- } while (numerosIngresados[index - 1] > 0);
- cout << "el numero mas grande ingresado fue: " << valorMaximo << endl;
- cout << "y se ubicaba en la posicion: " << valorPuntero + 1;
- }
- int valorMayor(int a, int b)
- {
- if (a > b)
- {
- b = a;
- }
- // Retornar algo
- return a;
- }
- */
- /*
- //EJERCICIO 3
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- const int cantidadMaxima = 500;
- const int mayoresQue = 100;
- const int menoresQue = -10;
- int main()
- {
- int numerosIngresados[cantidadMaxima];
- int index = 0;
- int valorMaximo = 0;
- int valorPuntero = 0;
- do
- {
- cout << "Ingresa un numero: ";
- cin >> numerosIngresados[index];
- if (numerosIngresados[index] > valorMaximo)
- {
- valorMaximo = numerosIngresados[index];
- valorPuntero = index;
- }
- index++;
- }while (numerosIngresados[index-1] > 0);
- cout << "el numero mas grande ingresado fue: " << valorMaximo << endl;
- cout << "y se ubicaba en la posicion: " << valorPuntero+1;
- }
- */
- /*
- // ejercicio 2
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- const int cantidadMaxima = 5;
- const int mayoresQue = 100;
- const int menoresQue = -10;
- int main()
- {
- int numerosIngresados[cantidadMaxima];
- int promedioNumeros = 0;
- int sumaNumeros = 0;
- int contadorDeNumeros = 0;
- int entrada = 0;
- for (int index = 0; index < cantidadMaxima; index++)
- {
- cout << "Ingresa un numero: ";
- cin >> numerosIngresados[index];
- if (numerosIngresados[index] > mayoresQue)
- {
- promedioNumeros = promedioNumeros + numerosIngresados[index];
- contadorDeNumeros++;
- }
- else if (numerosIngresados[index] < menoresQue)
- {
- sumaNumeros = numerosIngresados[index] + sumaNumeros;
- }
- }
- cout << "el promedio de los numeros mayores que 100 es: " << (promedioNumeros/contadorDeNumeros) << endl;
- cout << "la suma de los numeros menores que -10 es: " << sumaNumeros;
- }
- */
- /*
- //ejercicio 1.5
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- int main()
- {
- int unaVariable = 9999999999999999;
- int entrada = 0;
- for (int index = 0; index < 10; index++)
- {
- cout << "Ingresa un numero: ";
- cin >> entrada;
- if (entrada < unaVariable)
- {
- unaVariable = entrada;
- }
- }
- std::cout << unaVariable;
- }
- */
- /*
- //ejercicio 1
- #include "pch.h"
- #include <iostream>
- #include <sstream>
- using namespace std;
- int main()
- {
- int unaVariable = 0;
- int entrada = 0;
- for (int index = 0; index < 10; index++)
- {
- cout << "Ingresa un numero: ";
- cin >> entrada;
- if (entrada > unaVariable)
- {
- unaVariable = entrada;
- }
- }
- std::cout << unaVariable;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement