Generador de letras aleatorias [ESP-ENG] | C++
¿Qué tal? Acá estoy de nuevo, esta vez unificando un montón de código que he traido antes, dicho de una manera un poco resumida, reciclé bastante para esta nueva creación. Algo bastante común cuando hay proyectos parecidos o que toman herramientas antes trabajadas.
Hi! Here I am again, this time unifying a lot of code that I have brought before, in short, I recycled a lot for this new creation. Something quite common when there are similar projects or that take previously worked tools.
Para empezar las librerías ya son bastante conocidas por acá pero añadiría que hay algunas declaraciones de funciones, esto no lo había hecho antes porque no lo ví necesario. Ahora sí porque al ser muchas funciones había problemas en cuanto a como iba el flujo de código, pues algunas no reconocían a otras por el orden en el que habían sido colocadas. Para no perder mucho tiempo reorganizando y probando decidí resolverlo con las declaraciones.
La función selector la usé antes en la calculadora de divisores, de la cual hice dos versiones (los links están al final del post), para que fuese útil en este caso hice cambios en el texto a mostrar, retiré la comprobación de entrada por teclado y dejé el switch-case que recibe el número 1 o 0 respectivamente. Esto para decidir si se ejecuta la función "filter", "fondo_letra" y "exit" o se cierra el programa.
La función "zero" es parte de la función "fondo_letras", se trata de la función que usé para representar el 0 y también de la que partí para la letra "O" en la serie de publicaciones de letras en consola y números en consola respectivamente.
A continuación están todas las letras mostradas en la serie de cinco partes de letras en consola, exceptuando algunas variantes, pues decidí dejar solo las que me parecieran mejores para este programa. Es decir, están las 27 letras pero solo una versión de cada una de ellas, sin extras como había mostrado en algunas partes de la serie mencionada, esto para evitar preferencias en cuanto a probabilidad.
To begin with, the libraries are already well known around here but I would add that there are some function declarations, I had not done this before because I did not see it necessary. Now yes, because as there were many functions there were problems in terms of how the code flow went, because some did not recognize others by the order in which they had been placed. In order not to waste a lot of time reorganizing and testing I decided to solve it with the declarations.
I used the selector function before in the divisor calculator, of which I made two versions (the links are at the end of the post), to make it useful in this case I made changes in the text to display, I removed the keyboard input check and left the switch-case that receives the number 1 or 0 respectively. This to decide whether to execute the function "filter", "background_letter" and "exit" or close the program.
The function "zero" is part of the function "letter_background", it is the function I used to represent the 0 and also the one I started from for the letter "O" in the series of publications of letters in console and numbers in console respectively.
Below are all the letters shown in the five-part series of letters in console, except for some variants, because I decided to leave only those that I thought were best for this program. That is to say, there are the 27 letters but only one version of each one of them, without extras as I had shown in some parts of the mentioned series, this to avoid preferences in terms of probability.
La función "filter" también es reciclada, te sonará porque fue el mismo principio que usé para los "dados aleatorios", solo que con más condicionales if-else, pues ahora no son 10 posibilidades sino 27. Los tamaños ingresados son los mismos para todos excepto para la parte superior de la letra "ñ" y para la "t". Para la "ñ" hay un pequeño cambio en posicionamiento por estar compuesta de dos partes.
Para lograr que fuesen tomadas en cuenta todas las condiciones posibles, modifiqué la línea en la que la función rand() está, tomando en cuenta que fuese desde 1 hasta 27 y que cada condición corresponda a uno de estos números. El main solo contiene la clásica e innesecaria limpieza de pantalla que siempre suelo hacer por plantilla, la llamada del selector y el retorno.
The function "filter" is also recycled, it will sound you because it was the same principle that I used for the "random dice", only with more if-else conditionals, because now there are not 10 possibilities but 27. The sizes entered are the same for all except for the upper part of the letter "ñ" and for the "t". For the "ñ" there is a small change in positioning because it is composed of two parts.
To make sure that all possible conditions were taken into account, I modified the line where the rand() function is, taking into account that it should be from 1 to 27 and that each condition corresponds to one of these numbers. The main only contains the classic and unnecessary screen cleanup that I always do per template, the selector call and the return.
¡Y bueno... Eso es todo por hoy! Acá he reciclado tanto código que siento que hasta ayudé al medioambiente. Si sientes que no he explicado alguna parte del código que te interesaba aplicar en tu proyecto te recomiendo visitar las publicaciones 16,17,18,20,22,23,24,25,26,27. En estas encontrarás más sobre el graficado en consola, el selector, el uso de do-while y switch-case y la función con la que generaba números aleatorios para la selección de la letra a mostrar. Todos los links están debajo:
And well... That's all for today! Here I have recycled so much code that I feel I even helped the environment. If you feel that I have not explained some part of the code that you were interested in applying in your project I recommend you to visit the publications 16,17,18,20,22,23,24,25,26,27. In these you will find more about the graphing in console, the selector, the use of do-while and switch-case and the function with which I generated random numbers for the selection of the letter to show. All links are below:
Título/Tittle | LINK | Título/Tittle | LINK |
---|---|---|---|
Calculador de datos para un triángulo rectángulo en C++ | 1 | Graficando números en consola (0-3) C++ | 16 |
Concecionario de autos, ejercicio en JAVA | 2 | Graficando números en consola II (4-6) C++ | 17 |
Calculador de edad básico C++ | 3 | Graficando números en consola III (7-9) C++ | 18 |
Inversor de números de tres cifras | 4 | Calculadora de ecuaciones cuadráticas C++ | 19 |
¿Cuántos números de 3 cifras existen cuya suma sea 10? - ¡Respondiendo a otro usuario! C++ | 5 | Dados digitales C++ | 20 |
Calculadora simple, cifra menos significativa y portada simple C++ | 6 | Fichas biográficas de próceres C++ | 21 |
¡Vistazo a BeatUDO! JAVA | 7 | Calculadora de divisores C++ | 22 |
Comprobar si un número de dos cifras es primo C++ | 8 | Calculadora de divisores II C++ | 23 |
Conversor de pulgadas a 7 unidades distintas C++ | 9 | Graficando letras en consola I (ABCDE) C++ | 24 |
Comprobar si un número es capicúa (Máx 5 cifras) C++ | 10 | Graficando letras en consola II (FGHIJ) C++ | 25 |
Comprobador de caracteres C++ | 11 | Graficando letras en consola III (KLMNO) C++ | 26 |
Calculadora de índice de masa corporal C++ | 12 | Graficando letras en consola V (UVWXYZ) C++ | 27 |
Calculadora de factoriales C++ | 13 | X | X |
Conversor (Grados Celsius - Fahrenheit - Kelvin) C++ | 14 | X | X |
Calculadora de longitud, diametro y área de una circunferencia C++ | 15 | X | X |
https://twitter.com/gabrielrr018/status/1476287103696875524
The rewards earned on this comment will go directly to the person sharing the post on Twitter as long as they are registered with @poshtoken. Sign up at https://hiveposh.com.
Dear @gabrielr29,
The current HiveBuzz proposal will expire in a few days.
Do you mind supporting our proposal for 2022 so our team can continue its work next year?
You can do it on Peakd, ecency, Hive.blog or using HiveSigner.
https://peakd.com/me/proposals/199
Thank you. We wish you a Happy New Year!