Problema 1
1.- Inicio
void introdatos(int v[5][4]);
void sumarenglon (int v[5][4]);
void sumacolumna (int v[5][4]);
void imprimetabla(int v[5][4]);
void minimo (int v[5][4],int & min,int & posr,int & posc);
void maximo (int v[5][4],int & max,int & posr,int & posc);
void introdatos(int v[5][4])
{
r,c; Real
for (r=0; to 5 step ; r++)
{
for(c=0; to 4 step; c++)
{
Print "Datos" ,(r+1)," , ",(c+1)," :"
Read v[r][c];
}
}
}
void sumarenglon (int v[5][4])
{
suma, r, c Real
Print " Suma de renglon";
for (r=0; to 5 step; r++)
{
suma = 0;
for(c=0; to 4 step ; c++)
{
suma = suma + v[r][c];
}
Print " Renglon ",(r+1),":",suma;
}
}
void sumacolumna (int v[5][4])
{
suma, r, c; Real
Print " suma de columnas : ";
for(c=0; to 4 step; c++)
{
suma = 0;
for (r=0; to 5 step; r++)
{
suma = suma+v[r][c];
}
Print "La suma de la columna",(c+1),":","es:",suma;
}
}
void imprimetabla(int v[5][4])
{
r, c; Real
for (r=0; to 5 step; r++)
{
for(c=0; to 4 step; c++)
{
Print v[r][c],"\t";
}
Print ;
}
}
void minimo (int v[5][4],int & min,int & posr,int & posc)
{
r,c; Real
min = v[0][0];
posr = 0;
posc = 0;
for(r=0; to 5 step ;r++)
{
for(c=0;to 4 step;c++)
{
if(v[r][c]<min)
{
min = v[r][c];
posr = r;
posc = c;
}
}
}
}
void maximo (int v[5][4],int & max,int & posr,int & posc)
{
r,c; Real
max = v[0][0];
posr = 0;
posc = 0;
for(r=0;to 5 step ;r++)
{
for(c=0;to 4 step;c++)
{
if(v[r][c]>max)
{
max = v[r][c];
posr = r;
posc = c;
}
}
}
}
void main ()
{
valores[5][4] Real
pr1,pc1,pr2,pc2,max,min Real
introdatos(valores)
sumarenglon(valores)
sumacolumna(valores)
imprimetabla(valores)
maximo(valores,max,pr1,pc1)
minimo(valores,min,pr2,pc2)
Print "Desplegar el valor maximo ",max;
Print "entre la posiscion",pr1,",",pc1;
Print "Desplegar el valor minimo ",min;
Print"entre la posiscion",pr2,",",pc2;
Fin
Problema 2
Escriba un programa que sume los elementos equiparables de los arreglos bidimensionales
denominados “primero” y “segundo”. Ambos arreglos deben de tener 2 renglones y 3 columnas.
Por ejemplo los elementos [1][2] del arreglo que resulte deban ser la suma del primero y del segundo.
Los arreglos “primero” y “segundo” deben son introducidos por el usuario
1.- Inicio
void introdatos(int a[2][3], int b[2][3])
{
r,c; Real
for (r=0; to 3 step; r++)
{
for(c=0; to 2 step; c++)
{
Print "Datos" ,(r+1)," , ",(c+1)," :"
Read a[r][c]
Print "Datos" ,(r+1)," , ",(c+1)," :"
Read b[r][c]
}
}
}
void imprimedatos(int a[2][3],int b[2][3],int d[2][3])
{
r,c; Real
Print "1er num. + 2do num.";
cout<<endl;
for(r=0;to 3 step;r++)
{
for(c=0;to 2 step;c++)
{
Print a[r][c]," + ",b[r][c]," = ",d[r][c];
}
}
}
void sumardatos(int a[2][3],int b[2][3],int d[2][3])
{
r,c; Real
for(r=0;to 3 step;r++)
{
for(c=0;to 2 step;c++)
{
d[r][c] = a[r][c]+ b[r][c];
}
}
}
void main()
{
primer[2][3],segundo[2][3],tercer[2][3] Real
introdatos(primer,segundo);
sumardatos(primer,segundo,tercer);
imprimedatos(primer,segundo,tercer);
Fin
Problema 3
1.- Inicio
void introdatos(int m[4][4])
{
r,c; Real
randomize();
for(r=0;to 4 step;r++)
{
for(c=0; to 4 step;c++)
{
m[r][c]=random(10000)+1;
}
}
}
void imprimematriz(int m[4][4])
{
r,c; Real
for(r=0;to 4 step; r++)
{
for(c=0; to 4 step; c++)
{
cout<<m[r][c],"\t ";
}
}
}
void transpuesta(int m[4][4],int m1[4][4])
{
r,c; Real
for(r=0; to 4 step; r++)
{
for(c=0; to 4 step; c++)
{
m1[c][r] = m[r][c];
}
}
}
void main()
{
int a[4][4];
int a1[4][4];
introdatos(a);
transpuesta(a,a1);
imprimematriz(a);
imprimematriz(a);
Fin
Problema 4
1.- Inicio
void introdatos(int w[3])
{
i; Real
for(i=0; to 3 step; i++)
{
Print "w = ",(i+1);
Read w[i]
}
}
void introcalificacion(int m[5][3])
{
r,c; Real
for(r=0; to 5 step; r++)
{
for(c=0; to 3 step; c++)
{
Print "calificacion = ",(r+1),m[r][c];
}
}
}
void promedio(int m[5][3], int w[3], float c1[5])
{
r,c,suma; Real
for(r=0; to 5 step; r++)
{
suma=0;
for(c=0; to 3 step; c++)
{
suma = suma + m[r][c]*w[c];
}
c1[r] = suma/6.0;
}
}
void sumaw(int w[3])
{
i,s; Real
s=0;
for(i=0; o 3 step; i++)
{
s = s+w[i];
}
return s;
}
void rango(float c1[5], int r[5])
{
e,i,mayor,name; Real
for(e=0; to 5 step; e++)
{
mayor = 0;
for(i=0; to 3 step; i++)
{
if(c1[i]>mayor)
{
name = i;
mayor = c1[i];
}
}
r[name] = i;
c1[name] = 0;
}
}
void imprimir(int r[5])
{
i; Real
for(i=0; to 3 step; i++)
{
Print "No. estuduante: ",(i+1);
Print "suposicion en clase es : ",r[i];
}
}
void main()
{
int w[3];
int m[5][3];
float c1[5];
int r[5];
introdatos(w);
introcalificacion(m);
promedio(m, w, c1);
sumaw(w);
rango(c1, r);
imprimir(r);
Fin
Elaborar un programa que lea el nombre de  10 trabajadores y su produccion mensual por cada uno de los 12 meses del año, en dos arreglos uno para nombres y otro para produccion en los cuales las las "n" corresponden al trabajador.
Se requiere el siguiente reporte
Estacion                               Total Produccion
1                                                 xxxxxxx
2                                                 xxxxxxx
3                                                 xxxxxxx
4                                                 xxxxxxx
.
.
.
15                                               xxxxxxx
Total
Estacion mas productiva:________
Encargado de la Estación:__________
Cantidad Producida:___________
1.- Inicio
void calculoprodanual(int produccion[15][12],int prodtotal[15])
{
 i,j;      int
for(i=0;to 15 step;i++)
{
 suma=0    int
for(j=0;to 15 step;j++)
{
suma = suma+produccion[i][j]
Print produccion[i][j],"\t"
}
prodtotal[i] = suma
}
}
void introdatos(char nombre[15][20],int produccion[15][12])
{
 i,j;    int
randomize()
for(i=0;to 15 step;i++)
{
Print "Nombre del Encargado Estacion ",(i+1)," :"
Read nombre[i]
for(j=0;to 12 step;j++)
{
produccion[i][j] = random(50000)+1
Print produccion[i][j],"     ";
}
}
}
void mayorproductividad(int prod_total[15],int &mayor,int &pos)
{
 i;      int
mayor = prod_total[0]
pos = 0
for (i=1;to 15 step;i++)
{
if(prod_total[i]>mayor)
{
mayor = prod_total[i];
pos = i;
}
}
}
void main()
{
 prod[15][12]     int
 ptotal[15]        int
 nom[15][20]    char
 may,p1;      int
introdatos(nom,prod);
calculoprodanual(prod,ptotal);
mayorproductividad(ptotal,may,p1);
Print "La estacion mas productiva es:",(p1+1);
Print "Encargado de la estacion:",nom[p1];
Print "Cantidad producida:",ptotal[p1];
Fin.
Problema 6
Elaborar un programa que genere una matriz de 10x10 en la cual asigne ceros a todos los elementos excepto a los de la diagonal principal donde asignara unos, imprima dicha matriz.
1.- Inicio
void asignarvalores(int m[10][10])
{
r,c; Real
for(r=0; to 10 step; r++)
{
for(c=0; to 10 step; c++)
{
if(r==c)
{
m[r][c]=1;
}
else
{
m[r][c]=0;
}
}
}
}
void imprimematriz(int m[10][10])
{
i,c; Real
for(i=0; to 10 step; i++)
{
for(c=0; to 10 step; c++)
{
Print m[c][c]," ";
}
}
}
void main()
{
int matriz[10][10];
asignarvalores(matriz);
imprimematriz(matriz);
Fin
Problema 7
Elaborar un programa que de el informe de 10 trabajadores y su producción mensual los 12 meses en 2 arreglos. El informe debe de ir de la siguiente manera:
Nombre                                 Total de producción:
________                             ________________
________                             ________________
________                             ________________
Promedio de producción:______________
1.- Inicio
void introdatos(int produccion[10][13])
{
randomize ()
 i,j,suma;    real
for (i=0;to 10 step;i++)
{
suma = 0;
for (j=0;to 12 step;j++)
{
produccion[i][j] = random(5000)+1
suma = suma+produccion[i][j]
Print produccion[i][j],"\t";
}
produccion[i][12] = suma;
} }
void leernombres(char name[10][25])
{
int i;
for (i=0;to 10 step;i++)
{
Print "Nombre del Trabajador: ",(i+1)," : ";
cin.getline(name[i],25);
} }
void reporte(int produccion[10][13], char name[10][25])
{
 suma,i,prom;    real
Print " Analisis de Produccion  ";
Print " Nombre\t  Total Produccion ";
suma = 0;
for(i=0;to 10 step;i++)
{
Print name[i]," \t ",produccion[i][12]l
suma = suma+produccion[i][12]; }
prom = suma/10;
Print " Promedio de Produccion ",prom;
Print " Listado de Trabajadores Mayores a ",prom;
for (i=0;to 10 step;i++)
{
if (produccion[i][12]>prom)
{
Print name[i];
} } }
void main ()
{
 p[10][13]      real
 nom[10][25]      char
leernombres(nom)
introdatos(p)
reporte(p,nom)
Fin 
Problema 8
1.- Inicio
ifstream entrada;
entrada.open("c://datos//grupos.txt");
dato; Real
for(int j=1; to 3 step; j++)
{
for(int j=1; to 4 step; j++)
{
entrada,dato;
Print dato,"\t";
}
}
ofstream salida;
salida.open("c://datos//grupos.txt");
salida,"42 90 35 46",
salida,"28 76 31 92",
salida.close();
Print "datos almacenados";
Fin
Problema 9
Ejecute el archivo creado en el ejercicio 8 en un programa completo. Que realice la suma de los renglones y columnas de los valores dados en el archivo.
1.- inicio
void sumaren(int dato[3][4])
{
suma,i,j; real
Print "Suma de renglones: ";
for(i=0;to 3 step;i++)
{
suma = 0
for(j=0;to 4 step;j++)
{
suma = suma+dato[i][j]
}
Print "La suma del renglon: ",(i+1)," es: ",suma;
} }
void sumacol(int dato[3][4])
{
suma,i,j; real
Print "Suma de columnas: ";
for(j=0;to 4 step;j++)
{
suma = 0;
for(i=0;to 3 step;i++)
{
suma = suma+dato[i][j]
}
Print "La suma de las Columnas: ",(j+1)," es: ",suma;
} }
void imprimir(int dato[3][4])
{
i,j; real
ifstream entrada;
entrada.open("c://practica 9//prueba.txt");
for(i=0;to 3 step;i++)
{
for(j=0;to 4 step;j++)
{
entrada>>dato[i][j];
Print dato[i][j]<<" ";
}
}
entrada.close();
void main ()
{
dato[3][4] real
imprimir(dato)
sumaren(dato)
sumacol(dato)
Fin
Problema 10
1.- Inicio
ofstream f1;
f1.open("c://datos//grupos.txt");
f1,5;
f1,96;
f187;
f1,28;
f1,13;
f1,21;
f1,4;
f1,92;
f1,82;
f1,85;
f1,87;
f1,6;
f1,72;
f1,69;
f1,85;
f1,75;
f1,81;
f1,73;
f1.close();
Print "grupos almacenados";
i; Real
ifstream f2;
f2.open("c://datos//grupos.txt");
n,suma=0,numero; Real
f2,n;
for(int j=1;j<=n;j++)
{
f2,numero;
suma = suma + numero;
}
prom=suma/n; Real
Print "El promedio del grupo",i,":",prom;
f2.close();
Fin
Problema 11
1.- Inicio
fstream archivo;
archivo.open("c://datos//voltios.txt",ios::out);
archivo,"120.3 122.7 90.3 99.8";
archivo,"95.3 120.5 127.3 120.8";
archivo,"123.2 118.4 123.8 116.6";
archivo,"122.4 95.1 118.2 120.0";
archivo,"123.5 130.2 123.9 124.4";
archivo.close();
Print "archivo voltios almacenadatos";
Fin
fstream arch;
suma,num,prom; Float
arch.open("c://datos//voltios.txt",ios::out);
for(int i=1; to 5 step;i++)
{
for(int j=1; to 4 step; j++)
{
arch,num;
suma = suma+num;
}
prom = suma/4;
Print "el promedio del registro",i,": ",prom;
}
arch.close();
Fin
No hay comentarios:
Publicar un comentario