Diferencia entre revisiones de «matriz»

De ArduWiki
Saltar a: navegación, buscar
(EJemplo 1)
(Ejemplo 1)
Línea 23: Línea 23:
 
byte matriz1[] = {21,250,2,64};
 
byte matriz1[] = {21,250,2,64};
 
int matriz2[] = {2019,7,14,8,0,0};
 
int matriz2[] = {2019,7,14,8,0,0};
 +
</syntaxhighlight>
 +
 +
== Ejemplo 2 ==
 +
<syntaxhighlight lang="c++">
 +
int matriz[][6] = {{2019,7,14,8,0,0},{2019,7,19,8,0,0},{2019,7,22,8,0,0}};
 +
void setup(){
 +
  Serial.begin(9600);
 +
  for (i=0; i<3; i++){
 +
      for (j=0; j<7; j++){
 +
        Serial.print();
 +
      }
 +
  }
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revisión del 20:18 5 sep 2019

Descripcion

Una matriz es una variable que puede contener multiples elementos del mismo tipo.

Sintaxis

tipo nombre[] = {elemento1, elemento2...};
tipo nombre[][n] = {{1,2,3},{4,5,6},{7,8,9}};

Parámetros

tipo
puede ser char, byte, int, unsigned int, long, unsigned long o float.
nombre
es el nombre que se asignara a la matriz
n
Es el numero de elementos

Comentarios

  • En un matriz se puede obviar el numero de elementos (filas), pero en una matriz bidireccional es obligatorio indicar el numero de columnas.

Advertancia

Nada.

Ejemplo 1

byte matriz1[] = {21,250,2,64};
int matriz2[] = {2019,7,14,8,0,0};

Ejemplo 2

int matriz[][6] = {{2019,7,14,8,0,0},{2019,7,19,8,0,0},{2019,7,22,8,0,0}};
void setup(){
   Serial.begin(9600);
   for (i=0; i<3; i++){
      for (j=0; j<7; j++){
         Serial.print();
      }
   }
}

Vea también

Referencias externas