Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4. using namespace std;
  5.  
  6. // estructuras
  7. struct nombre
  8. {
  9. char n1 [50];
  10. char n2 [50];
  11. };
  12. struct apellido
  13. {
  14. char ap1[50];
  15. char ap2[50];
  16. };
  17.  
  18. struct practica
  19. {
  20. char materia [4][50];
  21. float promedio [4];
  22. float promF;
  23. };
  24. struct alumnos
  25. {
  26. nombre nom;
  27. apellido ape;
  28. int cod;
  29. };
  30. struct general
  31. {
  32. alumnos a;
  33. practica p;
  34. };
  35. //////////////// Funciones
  36.  
  37. void ingresar (general x[], int &na, int &mat)
  38. {
  39. cout << "\n\t INGRESE EL NUMERO DE ESTUDIANTES : "; cin >> na;
  40. cout << "\n\t INGRESE EL NUMERO DE MATERIAS: "; cin >> mat;
  41. system ("cls");
  42.  
  43. for (int i = 0 ; i < na ; i++)
  44. {
  45. system ("cls");
  46. /////// ALUMNOS
  47. cout << "\n\tNOMBRE (1): "; cin >> x[i].a.nom.n1;
  48. cout << "\n\tNOMBRE (2): "; cin >> x[i].a.nom.n2;
  49. cout << "\n\tAPELLIDO (1):";cin >> x[i].a.ape.ap1;
  50. cout << "\n\tAPELLIDO (2):";cin >> x[i].a.ape.ap2;
  51. cout << "\n\tCODIGO:"; cin >>x[i].a.cod;
  52. system ("cls");
  53. /////// MATERIAS
  54. for (int j =1 ; j <= mat ; j ++)
  55. {
  56.  
  57. cout << "\n\tMATERIA "<<j<<": "; cin >> x[i].p.materia[j];
  58. cout << "\n\tPROMEDIO "<<j<<": "; cin >> x[i].p.promedio[j];
  59. x[i].p.promF = (x[i].p.promF) + (x[i].p.promedio[j]);
  60.  
  61. }
  62. }
  63. }
  64. void consultar (general x[],int na, int mat)
  65. {
  66. system ("cls");
  67. int cd;
  68. int b = 0;
  69. float promedioF=0;
  70. cout << "INGRESE EL CODIGO DEL ESTUDIANTE: ";
  71. cin >>cd;
  72.  
  73.  
  74. for (int i = 0 ; i < na ; i++)
  75. {
  76. if (cd == x[i].a.cod)
  77. {
  78. b=1;
  79. /////// ALUMNOS
  80. cout << "\n\t\t DATOS DE "<<x[i].a.nom.n1;
  81. cout << "\n\tNOMBRE (1): "<<x[i].a.nom.n1;
  82. cout << "\n\tNOMBRE (2): "<<x[i].a.nom.n2;
  83. cout << "\n\tAPELLIDO (1):"<<x[i].a.ape.ap1;
  84. cout << "\n\tAPELLIDO (2):"<<x[i].a.ape.ap2;
  85. cout << "\n\tCODIGO:"<<x[i].a.cod;
  86.  
  87. /////// MATERIAS
  88. for (int j =1 ; j <= mat ; j ++)
  89. {
  90. cout << "\n\n\tMATERIA : "<<x[i].p.materia[j];
  91. cout << "\n\n\tPROMEDIO: "<<x[i].p.promedio[j];
  92.  
  93. promedioF =x[i].p.promF / mat;
  94. }
  95. cout << "\n\n\tPROMEDIO FINAL: "<<promedioF;
  96. cout << "\n\n\n";
  97. }
  98. }
  99. if (b==0)
  100. {
  101. cout <<"\n\t EL USUARIO NO CONSTA EN LA BASE DE DATOS";
  102. }
  103.  
  104. }
  105. void imprimir (general x[] , int na , int mat)
  106. {
  107. system ("cls");
  108. int comprobante;
  109. float promedioF=0;
  110. cout <<"inserte el codigo del alumno a buscar:";
  111. cin>>comprobante;
  112. for (int i = 0 ; i < na ; i++)
  113. {
  114.  
  115. if(comprobante==x[i].a.cod){
  116.  
  117. /////// ALUMNOS
  118. cout << "\n\tNOMBRE (1): "<<x[i].a.nom.n1;
  119. cout << "\n\tNOMBRE (2): "<<x[i].a.nom.n2;
  120. cout << "\n\tAPELLIDO (1):"<<x[i].a.ape.ap1;
  121. cout << "\n\tAPELLIDO (2):"<<x[i].a.ape.ap2;
  122. cout << "\n\tCODIGO:"<<x[i].a.cod;
  123.  
  124. /////// MATERIAS
  125. for (int j =1 ; j <= mat ; j ++)
  126. {
  127. cout << "\n\n\tMATERIA : "<<x[i].p.materia[j];
  128. cout << "\n\n\tPROMEDIO: "<<x[i].p.promedio[j];
  129.  
  130. promedioF =x[i].p.promF / mat;
  131. }
  132. cout << "\n\n\tPROMEDIO FINAL: "<<promedioF;
  133. cout << "\n\n\n";
  134. }}
  135. }
  136. int main ()
  137. {
  138. /// VARIABLES
  139. general x[4];
  140. int op;
  141. int na;
  142. int mat;
  143. ////
  144.  
  145. MENU:
  146. system ("cls");
  147. cout <<"\n\t==========MENU DE OPCIONES==========\n";
  148. cout <<"\n\t 1.INGRESAR.";
  149. cout <<"\n\t 2.CONSULTAR.";
  150. cout <<"\n\t 3.IMPRIMIR.";
  151. cout <<"\n\t 4.SALIR.";
  152. do{cout <<"\n\n\t INGRESE UNA OPCION: ";cin >> op;}while (op < 1 ||op > 4);
  153.  
  154. ///////////// DECLARACION DE MENU ///////////////////////
  155.  
  156. if (op ==1)
  157. {
  158. ingresar (x,na,mat);
  159. goto MENU;
  160. }
  161. else if (op ==2)
  162. {
  163. consultar (x,na,mat);
  164. getch ();
  165. goto MENU;
  166. }
  167. else if (op ==3)
  168. {
  169. imprimir (x,na,mat);
  170. getch ();
  171. goto MENU;
  172. }
  173. else
  174. {
  175. goto FIN;
  176. }
  177.  
  178. FIN:
  179. return 0;
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement