Author Archives: Juan Pablo Gonzalez Huezzo

#Mastery20 #TC1017

Use of loops with for:

Primero llamar la librería iostream y el poderoso using namespace std, después dentro del programa principal (int main() ) pedir una variable que defina nuestro ciclo.El ciclo for lleva un contador, el cual define la duracion del ciclo y en muchos casos el valor de la variable. El ciclo se puede ayudar de un i++ o un i–.

No se olviden de compilar y probar su programa aquí un ejemplo muy bueno:

 

 El código sin errores en:

https://github.com/JuanPabloGonzalezHuezzo/P2Triangle.cpp/blob/master/README.md

#Mastery19 #TC1017

LOOPS WITH WHILE

Primero llamar la librería iostream y el poderoso using namespace std, después dentro del programa principal (int main() ) pedir una variable que defina nuestro ciclo. Muy seguido la variable establecerá tu condición mediante un contador en el do while. Y con el while definiremos cuantas veces se repetirá el ciclo. Pero esto también se puede hacer con un ciclofor, es por eso que tambien se usa muy seguido para que el usuario del programa pueda definir con un caracter el número de veces que se repetira el ciclo.

Aquí un ejemplo de un ejercicio que realizamos en clase:

Notese que aquí sigue pidiendo una variable en ves de establecer un contador.//otra variable que ayuda al usuario

El link a un programa con un do while.

https://github.com/JuanPabloGonzalezHuezzo/WSQ09.cpp/blob/master/%23WSQ09.cpp

 

 

 

#Mastery18 #TC1017

Los condicionales son muy útiles, con ellos se define que cosa quieres que haga tu programa bajo diferentes circunstancias, hay muchas maneras de usarlos, por eso la explicación sería muy larga. Para poder hacer uso de los condicionales es necesario llamar la biblioteca y el poderoso “using namespace std;”. Después, dentro del programa principal, pedimos una variable, porque muy probablemente de esto nacerá tu condicional. Si hay más opciones que quieres poner dentro de la condición, tienes que ponerlas dentro de la condición inicial (casi siempre).

NOTA: la primer condición que se cumpla es la que realizará el programa y no buscará en las siguientes, a menos que lo escribas de manera correcta (en cascada). Se puede usar un if, despues un else, e ifelse, también se podría tomar en cuenta un do while pero es más un delimitador a base de una condición.

Primero les dare el ejemplo del proyecto final (Sudoku) en el cual por medio de condicionales if

(a los cuales tienes que ponerles la condicion por ejemplo    [

[…]

if(theBoard[r][c]!=0){

              cout

                                    }

          ]

)[…]

De esta manera se define que quieres que haga en el argumente cuando sucede cierta condición que escribes dentro de los parámetros.

el link al código es: https://github.com/kenwbauer/JuanPabloSquared/blob/master/sudoku.cpp

 

 

 

 

 

 

 

 

 

#TC1017 #Mastery17

El “switch” tiene diferentes usos, entre estos están condicional, variables tipo enteros y de caracter

//no agarra decimales!!

Las podemos usar para cambiar entre tipos de variables de manera sencill, y definiendo los valores de cada una!

Es como tener un codigo(no de programación), o definir una variable(no es una explicación precisa)

La syntaxis la saque del link al final:

Syntax

 

 
attr(optional) switch ( condition ) statement    
 

 

attr(C++11) any number of attributes
condition any expression of integral or enumeration type, or of a class type contextually implicitly convertible to an integral or enumeration type, or a declaration of a single non-array variable of such type with a brace-or-equals initializer.
statement any statement (typically a compound statement). case: and default: labels are permitted in statement and break; statement has special meaning.

 

 
attr(optional) case constant_expression : statement (1)  
 
attr(optional) default : statement (2)  
 

 

constant_expression a constant expression of the same type as the type of condition after conversions and integral promotions

De esta manera se puede lograr que funcione un switch.

un ejemplo puede ser el siguiente:

 

 

 

 

Si no te quedo claro, puedes visitar estas páginas:

http://en.cppreference.com/w/cpp/language/switch

El link al codigo en la imágen es el siguiente:https://github.com/JuanPabloGonzalezHuezzo/Mastery17/tree/master

#TC1017 #Mastery14

Creating your own libraries is really usefull to include a lot with ease.

It is relatively easy to create your own libraries, you just create you file named “mylibrary.cpp” and “a.h”. Then compile the library without a main program; this will create a file called “a.o”. After that you can your program with a main program and call your library as you would with any onther (#include ). Compile the program and add the library “a.o”. 

PS.- I saw another post where it said that could also act as a library.

 

#Mastery12 #Tc1017

Crear funciones es algo que permite que tu programa sea mucho más corto y sencillo, tanto de escribir, como de leer. Además es algo que se recomienda como un buen hábito al programar. De hecho es muy sencillo, los pasos son:

1) Se programa la función

2) Se define la función

3)Se utiliza la función en el programa principal

Las funciones sirven para la reutilización de código y así evitar el tener que escribir un código más largo e igual de útil. Puedes llamarlas de manera sencilla volviendo a nombrarlas después, como lo hacemos en el WSQ.

Un ejemplo es el sudoku, pero es muy complejo, un mejor ejemplo es el WSQ de lists que tiene varias funciones.

Aqui el link al WSQ08: https://github.com/JuanPabloGonzalezHuezzo/-WSQ08/blob/master/WSQ08.cpp

 

si buscas una explicación más detallada puedes visitar la siguiente página:

http://aprendecpp.com/blog/programacion-en-c-como-crear-funciones-i.html

#FinalProyect #TC1017 #Sudoku #summer

Well this proyect was an actual challenge for two main reasons. First my computer got broken and I had to install all the programs and buy another harddrive. After that both JP and me had to do another proyect for another class, and at the end we got toegether to finish the proyect. At the beginningwe shared ideas, but he did mostly all by his own, which was great, but I also felt left behind which was hard too. We got together to finish the final details and I felt I had done something, at least, at the end.

#Mastery06

To install Linux you need to choose which verison you want. I installed Ubuntu.  First you need a USB, and you save the Linux installer there. After that you plug the flashdrive to yo(turned off) and turn it on. Afterwards you need to access the boot menu. You do that by pressing one of these keyes: F1, F2, F11, when your computer is still turning on (before the windows logo [normally your computer’s brand logo appears at this time]).

This will show a window where it asks ask you wether you want to install linux and all you have left to do is press on that button. Once you have done that, you will have installed linux.

Another option, which is better in my opinion is install Linux in a flashdrive and access it through the boot menu. Our teacher Ken Bauer helped my by installing it in my USB, and this way I can use linux anytime qithout having to install it in my own computer.

This picture belongs to the booth menu.

And this one for the install button.

#WSQ16 #TC1017

https://github.com/JuanPabloGonzalezHuezzo/WSQ16/tree/master

Here is the code for the WSQ 16, I tried different ways to make it work, and failed. So I asked some friends for some help.

#WSQ15 #Tc1017

https://twitter.com/JPGHTC1017/status/596040379486449664

In that tweet there are pictures of the schedule I had for the end of the semester, unfortunately I couldn’t follow it completely.