More Related Content
Similar to Mauro yaguachi
Similar to Mauro yaguachi (20)
Mauro yaguachi
- 1. //#include <stdafx.h><br />#include <conio.h> <br />#include <windows.h><br />#include <string.h><br />#include <iostream.h> <br />//using namespace std;<br />#define cnt_max_string 10<br />#define cnt_char_ver 'x'<br />#define cnt_char_hor '-'<br />#define cnt_char_marco '*'<br />#define cnt_char_limpiar ' '<br />#define cnt_col_pant 5<br />#define cnt_fil_pant 2<br />#define cnt_col_mat 20<br />#define cnt_fil_mat 20<br />#define cnt_vec 20<br />#define cnt_num_campos 5<br />int VOPCION;<br />int VLV;<br />int Vfilas,Vcolumnas,edad;<br />int Vcodigo;<br />int Vbusqueda;<br />int Vfila_B;<br />struct Tpersona{<br />int codigo;<br />char nombres[cnt_max_string];<br />char direccion[cnt_max_string];<br />char telefono[cnt_max_string];<br />int edad;<br />}Vec_per[cnt_vec];<br />struct Tpersona Mat_per [cnt_fil_mat] [cnt_col_mat];<br />/*void gotoxy(int x, int y)<br />{<br /> COORD coord;<br /> coord.X = x;<br /> coord.Y = y;<br /> SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);<br />} */<br />void Linea (char Ptipo,char Pcaracter,int Pfil, int Pcol,int Pfili,int Pcoli)<br />{<br /> int vsm,vsmi,vsmf; <br /> int vsl,vsli,vslf; <br /> int vsinc;<br /> switch(Ptipo)<br /> {<br /> case 'V':<br /> vsli=(cnt_col_pant-1); vslf=((cnt_max_string*Pcol)+vsli+Pcol);<br /> vsmi=(cnt_fil_pant-1); vsmf=(((cnt_num_campos+1)*Pfil))+1;<br /> vsinc=cnt_max_string+1;<br /> break;<br /> case 'H':<br /> vsli=(cnt_fil_pant-1); vslf=(((cnt_num_campos+1)*Pfil))+1;<br /> vsmi=(cnt_col_pant-1); vsmf=((cnt_max_string*Pcol)+vsmi+Pcol);<br /> vsinc=cnt_num_campos+1;<br /> break;<br /> case 'X':<br /> vsli=Pcoli; vslf=Pcol; vsmi=Pfili; vsmf=Pfil; vsinc=Pcol-Pcoli;<br /> break;<br /> case 'Y':<br /> vsli=Pfili; vslf=Pfil; vsmi=Pcoli; vsmf=Pcol; vsinc=Pfil-Pfili;<br /> break;<br /> case 'L':<br /> vsli=Pfili; vslf=Pfil; vsmi=Pcoli; vsmf=Pcol; vsinc=1;<br /> break;<br /> }<br /> <br /> for (vsl=vsli;vsl<=vslf;vsl+=vsinc)<br /> {<br /> for (vsm=vsmi;vsm<=vsmf;vsm++)<br /> {<br /> switch(Ptipo)<br /> {<br /> case 'V': gotoxy(vsl,vsm); cout<< Pcaracter; break;<br /> case 'H': gotoxy(vsm,vsl); cout<< Pcaracter; break;<br /> case 'X': gotoxy(vsl,vsm); cout<< Pcaracter; break;<br /> case 'Y': gotoxy(vsm,vsl); cout<< Pcaracter; break;<br /> case 'L': gotoxy(vsl,vsm); cout<< Pcaracter; break;<br /> }<br /> }<br /> }<br />};<br />void Matriz (int Pfil, int Pcol, char Popcion)<br /> { <br /> int vsy=0;<br /> for (int vsf = 0 ; vsf < Pfil ; vsf++)<br /> {<br /> int vsx=0;<br />for (int vsc = 0 ; vsc < Pcol ; vsc++)<br /> {<br /> switch(Popcion)<br /> {<br /> case 'I':<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+0));<br /> cin>> Mat_per[vsf] [vsc].codigo;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+1));<br /> cin>> Mat_per[vsf] [vsc].nombres;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+2));<br /> cin>> Mat_per[vsf] [vsc].direccion;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+3));<br /> cin>> Mat_per[vsf] [vsc].telefono;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+4));<br /> cin>> Mat_per[vsf] [vsc].edad;<br /> break;<br /> case 'P':<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+0));<br /> cout<< Mat_per[vsf] [vsc].codigo;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+1));<br /> cout<< Mat_per[vsf] [vsc].nombres;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+2));<br /> cout<< Mat_per[vsf] [vsc].direccion;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+3)); <br /> cout<< Mat_per[vsf] [vsc].telefono;<br /> gotoxy(cnt_col_pant+vsx,(cnt_fil_pant+vsy+4));<br /> cout<< Mat_per[vsf] [vsc].edad;<br /> break;<br /> } // fin del switch<br /> vsx+=cnt_max_string+1;<br /> } // fin del for vsc <br /> vsy+=cnt_num_campos+1;<br />} // fin del for vsf<br /> }// fin del void matriz<br />void Vector (int Plv, char Popcion)<br /> { <br /> int vsy=0;<br /> for (int vsf = 0 ; vsf < Plv ; vsf++)<br /> {<br /> switch(Popcion)<br /> {<br /> case 'I':<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+0));cin>> Vec_per[vsf].codigo;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+1));cin>> Vec_per[vsf].nombres;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+2));cin>> Vec_per[vsf].direccion;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+3));cin>> Vec_per[vsf].telefono;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+4));cin>> Vec_per[vsf].edad;<br /> break;<br /> case 'P':<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+0));cout<< Vec_per[vsf].codigo;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+1));cout<< Vec_per[vsf].nombres;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+2));cout<< Vec_per[vsf].direccion;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+3));cout<< Vec_per[vsf].telefono;<br /> gotoxy(cnt_col_pant,(cnt_fil_pant+vsy+4));cout<< Vec_per[vsf].edad;<br /> break;<br /> case 'B':<br /> if (Vec_per[vsf].codigo == Vcodigo)<br /> {<br />Vbusqueda=1; <br /> Vfila_B=vsf;<br /> }<br /> break;<br /> } // fin del switch<br /> vsy+=cnt_num_campos+1;<br />} // fin del for vsf<br /> }// fin del void vector<br />void menu()<br />{ <br />// system(quot;
clsquot;
);<br />clrscr();<br />int vsbandera;<br />char vseliminar;<br />vsbandera=1;<br /> while (vsbandera!=0)<br /> { <br /> // system(quot;
clsquot;
);<br /> clrscr();<br /> //Linea ('L',cnt_char_limpiar,24,79,0,0);<br /> Linea ('X',cnt_char_marco,23,79,0,0);<br /> Linea ('Y',cnt_char_marco, 23, 79,0,0);<br /> gotoxy(5,5);<br /> cout<< quot;
Programa ejemplo del uso de estructuras con vectores y matrices quot;
; <br /> gotoxy(5,6);<br /> cout<< quot;
**************************************************************quot;
; <br /> gotoxy(5,7); cout<< quot;
1: Ingreso de MATRIZ DE (N x N) quot;
; <br /> gotoxy(5,8); cout<< quot;
2: Reporte de MATRIZ DE (N x N) quot;
; <br /> gotoxy(5,9); cout<< quot;
3: Ingreso de VECTOR DE (N) quot;
; <br /> gotoxy(5,10);cout<< quot;
4: Reporte de VECTOR DE (N) quot;
; <br /> gotoxy(5,11);cout<< quot;
5: Eliminación de Registr quot;
; <br /> gotoxy(5,12);cout<<quot;
DIGITE 0 PARA SALIR quot;
;<br /> gotoxy(5,13);<br /> cout<< quot;
**************************************************************quot;
; <br /> gotoxy(5,14);cout<<quot;
Opcion: < >quot;
;<br /> gotoxy(14,14);cin>> VOPCION;<br /> switch (VOPCION)<br /> { <br /> case 1:<br /> // system(quot;
clsquot;
);<br /> clrscr();<br /> Linea ('X',cnt_char_marco,25,79,0,0);<br /> Linea ('Y',cnt_char_marco, 25, 79,0,0);<br /> Linea ('X',cnt_char_marco,cnt_fil_pant+3,40,cnt_fil_pant-1,cnt_col_pant-1);<br /> Linea ('Y',cnt_char_marco, cnt_fil_pant+3, 40,cnt_fil_pant-1,cnt_col_pant-1);<br /> gotoxy(cnt_col_pant,cnt_fil_pant);<br /> cout<< quot;
Ingreso datos de una matriz quot;
;<br /> gotoxy(cnt_col_pant,cnt_fil_pant+1);<br /> cout<< quot;
Inserte filas de la matriz : quot;
;<br /> cin>> Vfilas;<br /> gotoxy(cnt_col_pant,cnt_fil_pant+2);<br /> cout<< quot;
Inserte columnas de la matriz: quot;
;<br /> cin>> Vcolumnas;<br />// system(quot;
clsquot;
);<br />clrscr();<br /> Linea ('V',cnt_char_ver, Vfilas, Vcolumnas,0,0);<br /> Linea ('H',cnt_char_hor, Vfilas, Vcolumnas,0,0);<br /> Matriz(Vfilas, Vcolumnas,'I');<br /> break; <br /> case 2:<br />// system(quot;
clsquot;
);<br /> clrscr();<br /> Linea ('V',cnt_char_ver, Vfilas, Vcolumnas,0,0);<br /> Linea ('H',cnt_char_hor, Vfilas, Vcolumnas,0,0);<br /> Matriz(Vfilas, Vcolumnas,'P');<br />while (getche() != '');<br />getche();<br /> break;<br /> case 3:<br /> // system(quot;
clsquot;
);<br /> clrscr();<br /> Linea ('X',cnt_char_marco,25,79,0,0);<br /> Linea ('Y',cnt_char_marco, 25, 79,0,0);<br /> Linea ('X',cnt_char_marco,cnt_fil_pant+3,40,cnt_fil_pant-1,cnt_col_pant-1);<br /> Linea ('Y',cnt_char_marco, cnt_fil_pant+3, 40,cnt_fil_pant-1,cnt_col_pant-1);<br /> gotoxy(cnt_col_pant,cnt_fil_pant); <br /> cout<< quot;
Ingreso de datos en un Vector quot;
;<br /> gotoxy(cnt_col_pant,cnt_fil_pant+1); <br /> cout<< quot;
Ingrese Longitud del Vector: quot;
;<br /> cin>>VLV;<br /> //system(quot;
clsquot;
);<br /> clrscr();<br /> Linea ('V',cnt_char_ver, VLV,1,0,0);<br /> Linea ('H',cnt_char_hor, VLV,1,0,0);<br /> Vector (VLV,'I');<br /> break;<br /> case 4:<br />// system(quot;
clsquot;
);<br />clrscr();<br /> Linea ('V',cnt_char_ver, VLV,1,0,0);<br /> Linea ('H',cnt_char_hor, VLV,1,0,0);<br /> Vector (VLV,'P');<br />while (getche() != '');<br />getche();<br /> break;<br /> case 5:<br /> // system(quot;
clsquot;
);<br /> clrscr();<br /> Vbusqueda=0;<br /> Linea ('X',cnt_char_marco,25,79,0,0);<br /> Linea ('Y',cnt_char_marco, 25, 79,0,0);<br /> Linea ('X',cnt_char_marco,cnt_fil_pant+3,40,cnt_fil_pant-1,cnt_col_pant-1);<br /> Linea ('Y',cnt_char_marco, cnt_fil_pant+3, 40,cnt_fil_pant-1,cnt_col_pant-1);<br /> gotoxy(cnt_col_pant,cnt_fil_pant); cout<< quot;
Busqueda en un Vector quot;
;<br /> gotoxy(cnt_col_pant,cnt_fil_pant+1); cout<< quot;
Ingrese codigo: quot;
;<br /> cin>>Vcodigo;<br />// system(quot;
clsquot;
);<br />clrscr();<br /> Linea ('V',cnt_char_ver, VLV,1,0,0);<br /> Linea ('H',cnt_char_hor, VLV,1,0,0);<br /> Vector (VLV,'P');<br /> Vector (VLV,'B');<br /> if (Vbusqueda==1)<br /> {<br /> Linea ('X',cnt_char_marco,cnt_fil_pant+14,60,cnt_fil_pant-1,cnt_col_pant-1);<br /> Linea ('Y',cnt_char_marco, cnt_fil_pant+14,60,cnt_fil_pant-1,cnt_col_pant-1);<br /> gotoxy(cnt_col_pant+15,cnt_fil_pant+3);<br /> cout<< quot;
Desea eliminar el registro S/N : quot;
;<br /> cin>>vseliminar; <br /> switch (vseliminar)<br /> { <br /> case 's':case 'S':<br /> Vec_per[Vfila_B].codigo=0;<br /> strcpy(Vec_per[Vfila_B].nombres,quot;
quot;
);<br /> strcpy(Vec_per[Vfila_B].direccion,quot;
quot;
);<br /> strcpy(Vec_per[Vfila_B].telefono,quot;
quot;
);<br /> Vec_per[Vfila_B].edad=0;<br />// system(quot;
clsquot;
);<br /> Linea ('V',cnt_char_ver, VLV,1,0,0);<br /> Linea ('H',cnt_char_hor, VLV,1,0,0);<br /> Vector (VLV,'P');<br /> break;<br />} <br /> }<br />while (getche() != '');<br />getche();<br /> break;<br /> case 0:<br />cout<<quot;
quot;
;<br />cout<< quot;
Pulse cualquier tecla para continuarquot;
;<br />getche();<br />vsbandera=0;<br /> }<br /> }<br /> }<br />void main(void)<br /> { menu(); }<br />