Este documento contiene varios ejemplos de código C++ que utilizan arreglos multidimensionales para almacenar y manipular diferentes tipos de datos, incluyendo letras, números y otros valores. Los ejemplos muestran cómo definir arreglos, solicitar entrada de datos para llenarlos, y luego imprimir o sumar los valores almacenados.
6. #include <stdio.h>
#include <iostream>
using namespace std;
int main ()
{
char vocales [10] ={'a','e','i','o','u','A','E','I','O','U'};
int Rangos[6][2]= {1,10,
11,20,
21,30,
31,40,
41,50,
51,60};
float Z[10]={12.5,3.25,1.5,34.67,7.6,4.0,89.6,4.5,9.0,19.5};
int R,C;
printf ("n Inicia arreglos con valores especificos n");
printf ("-------------------- nn");
printf ("Arreglo iniciado de vocales n n");
7. for (R=0; R<10; R++)
printf ("%c,",vocales[R]);
printf("nn Arreglo inciado de Rangos nn");
for (R=0; R<6; R++)
{
for (C=0; C<2;C++)
printf ("%3d",Rangos [R][C]);
printf("n");
}
printf("n n Arreglo inciado de numeros reales n n");
for(R=0; R<10; R++)
printf("%5.2f",Z[R]);
printf("n n");
system("PAUSE");
return 0;
}
8. #include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int Numeros[4][5][5]; int Pri,Ren,Col;
printf("nLEE NUMEROS EN UN ARREGLO TRIDIMENSIONALn");
printf(" Y LOS IMPRIME EN LA PANTALLAn");
printf("NUMEROS[PRIMERA][SEGUNDA][TERCERA]n");
for (Pri=0; Pri<4; Pri++)
{
for (Ren=0; Ren<5; Ren++)
{
for (Col=0; Col<5; Col++)
{
printf("NUMERO[%d][%d][%d]: ",Pri,Ren,Col); scanf("%d",&Numeros[Pri][Ren][Col]);
}
printf("n");
}
}
for (Pri=0; Pri<4; Pri++)
13. #include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int Numeros[4][5][5]; int Pri,Ren,Col;
printf("nLEE NUMEROS EN UN ARREGLO TRIDIMENSIONALn");
printf(" Y LOS IMPRIME EN LA PANTALLAn");
printf("NUMEROS[PRIMERA][SEGUNDA][TERCERA]n");
for (Pri=0; Pri<4; Pri++)
{
for (Ren=0; Ren<5; Ren++)
{
for (Col=0; Col<5; Col++)
{
printf("NUMERO[%d][%d][%d]: ",Pri,Ren,Col); scanf("%d",&Numeros[Pri][Ren][Col]);
}
printf("n");
}
}
for (Pri=0; Pri<4; Pri++)
15. #include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
char aut[2][2];
int responsable[2][2];
int R,C,R1,C1;
printf("matriz de taller");
for(R=0;R<2; R++)
{
for(C=0;C<2;C++)
{
printf("n cual es el aut?[%c][%c]:",R,C);
scanf("%c",&aut[R][C]);
}
}
for(R1=0;R1<2;R1++)
{
16. for(C1=0;C1<2;C1++)
{
printf("n numero de responsable[%d][%d]:",R1,C1);
scanf("%d",&responsable[R1][C1]);
}
}
system("PAUSE");
return 0;
}
17. #include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
int numeros [4][5][5];
int sum, res, mul;
{
for (sum=0; sum<4; sum++)
{
for (res=0, res<5, res++)
{
for (mul=0, mul<5, mul++)
{
printf("n teclee los valores [%d] n");
scanf ("%d",&numeros[sum][res][mul]);
}
numeros[4][5][5]= numeros[4][5][5]+ numeros [4][5][5];
printf ("el valor de numeros [4][5][5] [%d]", numeros [4][5][5];