Tag Archives: #Mastery26

Mastery 26

26 1017

Una matriz es un vector de vectores o un también llamado array bidimensional. La manera de declarar una matriz es C++ es similar a un vector:

int matrix[rows][cols];

int es el tipo de dato, matrix es el nombre del todo el conjunto de datos y debo de especificar el numero de filas y columnas.

Las matrices también pueden ser de distintos tipos de datos como char, float, double, etc. Las matrices en C++ se almacenan al igual que los vectores en posiciones consecutivas de memoria.

Usualmente uno se hace la idea que una matriz es como un tablero, pero internamente el manejo es como su definición lo indica, un vector de vectores, es decir, los vectores están uno detrás del otro juntos.

La forma de acceder a los elementos de la matriz es utilizando su nombre e indicando los 2 subíndices que van en los corchetes.

Si coloco int matriz[2][3] = 10; estoy asignando al cuarto elemento de la tercera fila el valor 10.

 

No olvidar que tanto filas como columnas se enumeran a partir de 0. Bueno y para recorrer una matriz podemos usar igualmente un bucle. En este caso usando 2 for:

for(inti = 0; i
  for(intj = 0; j
    matrix[i][j] = i % j;
  }
}

Mastery 23 y 26

23 26 1017

Un vector, también llamado array(arreglo) unidimensional, es una estructura de datos que permite agrupar elementos del mismo tipo y almacenarlos en un solo bloque de memoria juntos, uno despues de otro. A este grupo de elementos se les identifica por un mismo nombre y la posición en la que se encuentran. La primera posición del array es la posición 0.

Podríamos agrupar en un array una serie de elementos de tipo enteros, flotantes, caracteres, objetos, etc.

Crear un vector en C++ es sencillo, seguimos la siguiente sintaxix: Tipo nombre[tamanyo];

Ejm:

 
 
 
int a[5]; // Vector de 5 enteros
float b[5]; // vector de 5 flotantes
Producto product[5]; // vector de 5 objetos de tipo Producto

Podríamos también inicializar el vector en la declaración:

 
 
 
int a[] = {5, 15, 20, 25, 30};
float b[] = {10.5, 20.5, 30.5, 12.5, 50.5}
Producto product[] = {celular, calculadora, camara, ipod, usb}

Como hay 5 elementos en cada array, automáticamente se le asignará 5 espacios de memoria a cada vector, pero si trato de crear el vector de la forma int a[] , el compilador mostrará un error, porque no indiqué el tamaño del vector ni tampoco inicializé sus elementos.

https://ronnyml.wordpress.com/2009/07/04/vectores-matrices-y-punteros-en-c/

Tambien estos incluyen las matrices.

las cuales funcionan:

bidimensional. La manera de declarar una matriz es C++ es similar a un vector:

1
int matrix[rows][cols];

int es el tipo de dato, matrix es el nombre del todo el conjunto de datos y debo de especificar el numero de filas y columnas.

Las matrices también pueden ser de distintos tipos de datos como char, float, double, etc. Las matrices en C++ se almacenan al igual que los vectores en posiciones consecutivas de memoria.

Usualmente uno se hace la idea que una matriz es como un tablero, pero internamente el manejo es como su definición lo indica, un vector de vectores, es decir, los vectores están uno detrás del otro juntos.

La forma de acceder a los elementos de la matriz es utilizando su nombre e indicando los 2 subíndices que van en los corchetes.

Si coloco int matriz[2][3] = 10; estoy asignando al cuarto elemento de la tercera fila el valor 10.

Creation and Use of Strings in Python. Mastery 26.

A string is a sequence of characters. You can access the characters one at a time with the bracket operator.

Per example, let’s declare a string variable called car containing a sequence of characters forming the word mazda6.

In this example I’m calling the character corresponding to the third value of index of characters. Remember that the index starts at 0, so the character 0 will be c, the character 1 a, the character 2 z and so on.

Len.

The function len is able to return the numbers of characters contained in a string. Example:

 

If you want to get the last character of a string you can try something like this:

Traversal.

The process of dealing one string character at time and doing something to it, is called traversal processing.

Example:

This prints individually each of the characters contained inside the car string.

Slices.

Slices are segment of strings. Selecting slices of a certain strings is really easy.

Example:

The slice that I’m calling in this example is one going from the index 0 to the 4th index. Notice that using the 5 in the brackets means calling the previous character in the index. So the bracket works something like this [firstindex:lastindex+1].

Because…

Immutability.

Strings are immutable, that meaning that you are not able to change an existing string. The best thing you can do to deal with this is creating a new string that is a variation from the original.

Example, let’s call a new model ‘mazda3’:

You can appreciate that I’m calling the slice that contains the word ‘mazda’ and I’m adding a ‘3’ to the end, so I have a new string called new model containing the string ‘Mazda3’

Counting.

Also, you can go a little forward and count the times that a character appears in a string. Let’s count how many times the ‘a’ appears in ‘Mazda6’.

 

These are somes of the things that you can do with a string. Have fun 😀

 

 

26

Mastery 26

Here is my code for the 26th mastery for Kens TC1017 C++ course via GitHub: mastery26

Here is a picture of the code running on my MacBook:

1017 26

Mastery 26

Mastery 26

#Mastery26 #TC1017

Creation and use of matrixes in C++

Les dejo un tutorial donde se explica la deficion de matriz, su uso y sus ventajas, espero que les guste: 

 

 

YOUTUBE:

 

http://youtu.be/XMjujgUSyAs?hd=1

Mastery 26


***STRINGS***

Los strings o cadenas, son una secuencia o serie de caracterres con los cuales podemos armas frases principalmente sin embargo  estos poseen determinadas maneras de presentarse o “jugar” con ellos por ejemplo:

– DEFINIENDO CADENAS:

Lo esencial que hay que considerar a la hor de usar strings es que siempre tienen que ir acompañados de las comillas dobles (“”) o también puede ser con las comillas simples (”), no hay diferencia en el uso ambas cumplen la misma función. 

 

 

– INMUTABLES:

 

– BÚSQUEDA:

       

 

– REMPLAZO DE TEXTO:

 

– DIVISIÓN Y UNIÓN DE TROZOS:

 

Para más información: http://www.maestrosdelweb.com/guia-python-cadenas-de-texto/

#mastery26 https://www.youtube.com/watch?v=vlSAf0kOe68

Mastery 26

26. Creation and use of strings in Python

Mastery 26


YOU CAN SEE THE PROGRAM DESCRIPTION AND THE LINK THAT REDIRECTS YOU TO THE PROGRAM FILE ON GITHUB BELOW 👇🌸


Mastery26 (Video)

GitHub link

Mastery 26

Uso de cadenas #Mastery26 #TC1014

this is the link for my video:

Uso de cadenas #Mastery26 #TC1014