Mauro yaguachi

1,628 views
1,545 views

Published on

Published in: Travel, Entertainment & Humor
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,628
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mauro yaguachi

  1. 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("cls");<br />clrscr();<br />int vsbandera;<br />char vseliminar;<br />vsbandera=1;<br /> while (vsbandera!=0)<br /> { <br /> // system("cls");<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<< " Programa ejemplo del uso de estructuras con vectores y matrices "; <br /> gotoxy(5,6);<br /> cout<< "**************************************************************n"; <br /> gotoxy(5,7); cout<< "1: Ingreso de MATRIZ DE (N x N) "; <br /> gotoxy(5,8); cout<< "2: Reporte de MATRIZ DE (N x N) "; <br /> gotoxy(5,9); cout<< "3: Ingreso de VECTOR DE (N) "; <br /> gotoxy(5,10);cout<< "4: Reporte de VECTOR DE (N) "; <br /> gotoxy(5,11);cout<< "5: Eliminación de Registr "; <br /> gotoxy(5,12);cout<<" DIGITE 0 PARA SALIR ";<br /> gotoxy(5,13);<br /> cout<< "**************************************************************"; <br /> gotoxy(5,14);cout<<"Opcion: < >";<br /> gotoxy(14,14);cin>> VOPCION;<br /> switch (VOPCION)<br /> { <br /> case 1:<br /> // system("cls");<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<< "Ingreso datos de una matriz ";<br /> gotoxy(cnt_col_pant,cnt_fil_pant+1);<br /> cout<< "Inserte filas de la matriz : ";<br /> cin>> Vfilas;<br /> gotoxy(cnt_col_pant,cnt_fil_pant+2);<br /> cout<< "Inserte columnas de la matriz: ";<br /> cin>> Vcolumnas;<br />// system("cls");<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("cls");<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() != 'n');<br />getche();<br /> break;<br /> case 3:<br /> // system("cls");<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<< "Ingreso de datos en un Vector ";<br /> gotoxy(cnt_col_pant,cnt_fil_pant+1); <br /> cout<< "Ingrese Longitud del Vector: ";<br /> cin>>VLV;<br /> //system("cls");<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("cls");<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() != 'n');<br />getche();<br /> break;<br /> case 5:<br /> // system("cls");<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<< "Busqueda en un Vector ";<br /> gotoxy(cnt_col_pant,cnt_fil_pant+1); cout<< "Ingrese codigo: ";<br /> cin>>Vcodigo;<br />// system("cls");<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<< "Desea eliminar el registro S/N : ";<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,"");<br /> strcpy(Vec_per[Vfila_B].direccion,"");<br /> strcpy(Vec_per[Vfila_B].telefono,"");<br /> Vec_per[Vfila_B].edad=0;<br />// system("cls");<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() != 'n');<br />getche();<br /> break;<br /> case 0:<br />cout<<"n";<br />cout<< "nPulse cualquier tecla para continuar";<br />getche();<br />vsbandera=0;<br /> }<br /> }<br /> }<br />void main(void)<br /> { menu(); }<br />

×