2. #include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
char abecedario[2][2][28][1];
char R,C,R1,C1;
printf("abecedario[PRIMERA][SEGUNDA][TERCERA][CUARTA]n");
for (R=0; R<2; R++)
{
for (C=0; C<2; C++)
{
for (R1=0; R1<28; R1++)
{
for (C1=0; C1<1; C1++)
}
}
printf("abecedario[%c][%c][%c][%c]: n",R,C,R1,C1);
scanf("%c",&abecedario[R][C][R1][C1]);
}
printf("n");
}
}
for (R=0; R<1; R++)
{
for (C=0; C<1; C++)
{
for (R1=0; R1<1; R1++)
{
for (C1=0; C1<1; C1++)
printf("%c",abecedario[R][C][R1][C1]);
}
printf("n");
}
}
system ("PAUSE");
return 0;
}
Arreglo Unidimensional
#include <iostream> /* LIBRERIAS*/
#include <stdio.h>
int main() /* FUNCION FUENTE*/
{
3. int suma[5];
int J;
for (J=0; J<=4; J++);
{
printf("el valor de [%d]",J+1);
scanf("%d",&suma[J]);
}
suma[5] = suma [2]+ suma[3];
printf("el valor de [5] [%d]",suma [5]);
system ("pause");
return 0;
}
Arreglo
#include <stdio.h>
#include <iostream>
int main();
{
int Numeros[4][5]; int Ren,Col;
printf("nLEE E IMPRIME NUMEROS EN UNA MATRIZn");
for (Ren=0; Ren<=3; Ren++)
{
for (Col=0; Col<=4; Col++)
{
printf("TECLEE EL VALOR [%d][%d]: ",Ren,Col); Scanf("%d",&Numeros[Ren][Col]);
}
}
printf(" M A T R I Znn");
for (Ren=0; Ren<=3; Ren++)
{
for (Col=0; Col<=4; Col++)
{
printf("%5d ",Numeros[Ren][Col]);
}
printf("n");
}
printf("nPRESIONE <Intro> PARA CONTINUAR..."); fflush(stdin); getchar();
}
Arreglo Tridimencional
#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");
4. 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++)
{
printf("nn------------MATRIZ %d ------------n",Pri);
for (Ren=0; Ren<5; Ren++)
{
for (Col=0; Col<5; Col++)
{
printf("%4d ",Numeros[Pri][Ren][Col]);
}
printf("n");
}
}
printf("nPRESIONE <Intro> PARA CONTINUAR..."); fflush(stdin); getchar();
system ("pause");
return 0;
}
Arreglo
#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");
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++)
5. 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;
}
Auto y responsables
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
char car[2][2];
int own [2][2];
int R,C,R1,C1;
for(R=0;R<=1;R++)
{
for(C=0;C<=1;C++)
{
printf("nCual es la marca del auto? [%c][%c]:",R,C);
scanf("%c",&car[R][C]);
}
}
for(R1=0; R1<=1; R1++)
{
for(C1=0;C1<=1;C1++)
{
printf("Numero de Responssable [%d][%d]:",R1,C1);
scanf("%d",&own[R1][C1]);
}
}
system ("pause");
return 0;
}
Perro
#include <iostream>
using namespace std;
class
{
public :
perro (int initialAge);
~perro();
int GetAge ()
6. {
return itsAge;
}
void SetAge (int age)
{
itsAge = age;
}
void Ladra ()
{
cout <<"Guau Guau... n";
}
private:
int itsAge;
};
Practica final
#include <stdlib.h>
#include <iostream>
int main()
{
char alfabeto [1][2][4][7];
printf("letras mayusculas del alfabeton");
int re,ce,r,c;
for(re=0;re<1;re++)
{
for(ce=0;ce<2;ce++)
{
for(r=0;r<4;r++)
{
for(c=0;c<7;c++)
{
printf("introdusca
las letras del alfaveto[%d][%d][%d][%d] : n",re,ce,r,c);
scanf("%c",&alfabeto
[re][ce][r][c]);
fflush(stdin);
}
}
}
}
printf(" n");
printf("las letras
en el alfabeto son : n");
for(re=0;re<=1;re++)
{
for(ce=0;ce<2;ce++)
{
for(r=0;r<4;r++)
{
for(c=0;c<7;c++)
{
printf("%c",alfabeto[re][ce][r][c]);
}
}
7. }
}
system("PAUSE");
return EXIT_SUCCESS;
}
Practica Perro
#include "Perro.hpp"
perro::perro (int initialAge)
{
itsAge= initialAge;
}
perro::~perro()
{
cout<<"objeto destruido"<< endl;
}
int main ()
{
bool test = false;
perro Canelo (5);
Canelo.Ladra();
cout<<"Canelo es un perro cuya edad es:";
cout<<Canelo.GetAge ()<< "añosn";
Canelo.Ladra ();
Canelo.SetAge (7);
cout<<"Ahora Canelo tiene";
cout<<Canelo.GetAge()<<"añosn n";
system ("PAUSE");
return 0;
}
Prueba
#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]);
8. }
printf("n");
}
}
for (Pri=0; Pri<4; Pri++)
{
printf("nn------------MATRIZ %d ------------n",Pri);
for (Ren=0; Ren<5; Ren++)
{
for (Col=0; Col<5; Col++)
{
printf("%4d ",Numeros[Pri][Ren][Col]);
}
printf("n");
}
}
system ("PAUSE");
return 0;
}
Taller mecanico
#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++)
{
for(C1=0;C1<2;C1++)
{
printf("n numero de responsable[%d][%d]:",R1,C1);
scanf("%d",&responsable[R1][C1]);
}
}
system("PAUSE");
return 0;
}
Tridimencional (suma, divicion,resta y promedio)
9. #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];
system("PAUSE");
return 0;
}