UNIDAD 3: ARREGLOS

TEMA LINUX GCC 7: ARREGLOS TIPO TABLA

Un arreglo tipo tabla se define como un conjunto de datos del mismo tipo organizados en dos o mas columnas y uno o mas renglones.

Para procesar ( recordar solo operaciones y comparaciones) internamente todos los elementos de la tabla se ocupan dos ciclos for(), uno externo para controlar renglón y uno interno para controlar columna.

Los elementos de la tabla se deberan simbolizar con el nombre de la tabla y 2 subindices, el primer subindice referencia al renglon y el siguiente subindice referencia la columna.

La declaración de una tabla sera de acuerdo al siguiente formato.

tipo nomtabla[cant ren][cant col];

ejemplo:

int calif[3][4];

long int ingresos [3][4];

Para capturar sus elementos, usaremos tantos input text's como celdas tenga la tabla.

Para efectuar otros procesos tales como operaciones despliegue con todos los elementos de la tabla se deberan usar 2 ciclos un for externo para controlar renglon y un for interno para controlar columna.

Prog12.html


<HTML>

<form action=/~tusitio/cgi-bin/prog12.cgi method=post>

<B> CONCENTRADO CALIFICACIONES</B><br>

..........enero.......febrero....marzo<br>

juan...:<INPUT TYPE=text NAME=cerocero size=5>

<INPUT TYPE=text NAME=cerouno size=5>

<INPUT TYPE=text NAME=cerodos size=5><br>

pedro:<INPUT TYPE=text NAME=unocero size=5>

<INPUT TYPE=text NAME=unouno size=5>

<INPUT TYPE=text NAME=unodos size=5><br>

<input type=submit value=ok>

<input type=reset>

</form> </HTML>

corrida:

image58.jpg

prog12.cpp


#include <iostream>

#include <string>

#include <string.h>

#include <lcnet.h>

using namespace std;

int main()

{

// declarando arreglos y var de control

int calif[2][3], ren, col;

// capturando aqui no se puede usar un ciclo

calif[0][0]=getinteger("cerocero");

calif[0][1]=getinteger("cerouno");

calif[0][2]=getinteger("cerodos");

calif[1][0]=getinteger("unocero");

calif[1][1]=getinteger("unouno");

calif[1][2]=getinteger("unodos");

// operaciones usar dos ciclos for y regalando 10 puntos

for(ren=0;ren<=1;ren++)

for(col=0;col<=2;col++)

calif[ren][col] = calif[ren][col] +10;

//empezando a construir la pagina de salida

cout << "Content-type: text/html\n\n";

cout << "<html>" << endl;

//DESPLEGANDO USANDO OBJETO TABLE DE HMTL FOR NORMAL

cout <<"<table border=2><tr><b>CALIF + 10</b></tr>" << endl;

for(ren=0;ren<=1;ren++)

{cout <<"<tr>" << endl ;

for(col=0;col<=2;col++)

cout<<"<td>"<< calif[ren][col] << "</td>" << endl;

cout <<"</tr>" <<endl; };

cout << "</html>" << endl;

return 0;

}

corrida:

image59.jpg

TAREAS PROGRAMACION LINUX GCC PROGRAMACION LINUX GCC

1.- CONSTRUIR UN CUADRO QUE CONTENGA LOS COSTOS FIJOS DE CUATRO PRODUCTOS CUALESQUIERA, QUE SE PRODUCEN EN TRES PLANTAS DIFERENTES DE UNA EMPRESA MAQUILADORA.

2.- CONSTRUIR UN CUADRO QUE CONTENGA LOS INGRESOS MENSUALES POR VENTAS DURANTE LOS TRES PRIMEROS MESES DEL AÑO DE CUATRO SUCURSALES DE UNA CADENA DE AUTO REFACCIONES, AGREGAR AL FINAL UNA LISTA QUE MUESTRE LOS INGRESOS MENSUALES TOTALES POR MESES Y UNA SEGUNDA LISTA QUE MUESTRE LOS INGRESOS MENSUALES TOTALES POR SUCURSAL.

3.-CONSTRUIR UN CUADRO QUE CONTENGA LAS COMISIONES GANADAS POR TRES VENDEDORES, DE LOS 5 TIPOS DE LINEA BLANCA DE CONOCIDA MUEBLERIA, ADEMAS LISTAS DE COMISIONES TOTALES Y PROMEDIOS GANADAS POR LOS VENDEDORES, ASI COMO LISTAS DE COMISIONES TOTALES Y PROMEDIOS POR TIPO DE LINEA BLANCA.

ANALIZAR ESTE CODIGO:


' PARA TOTALES Y PROMEDIOS POR RENGLON

FOR R = 0 TO 3

FOR C = 0 TO 2

TOTRENG(R) = TOTRENG(R) + TABLA(R,C)

NEXT C

PROMRENG(R) = TOTRENG(R)/3

NEXT R

'PARA TOTALES Y PROMEDIOS POR COLUMNA

FOR C = 0 TO 2

FOR R = 0 TO 3

TOTCOL(C)=TOTCOL(C) + TABLA(R,C)

NEXT R

PROMCOL(C) = TOTCOL(C) / 4

NEXT C

SUGERENCIA: CONSTRUIR PRIMERO LOS CUADROS EN PAPEL.

 




Google
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Politica de Privacidad