Foro de elhacker.net

Programación => Programación C/C++ => Mensaje iniciado por: geshiro en 6 Abril 2015, 02:47 am



Título: quien me ayuda hacer el de modificar
Publicado por: geshiro en 6 Abril 2015, 02:47 am
Código
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4. #include <windows.h>
  5.  
  6. int ca=0;
  7. int buscar = 0;
  8. int x=0;
  9. int resp=0;
  10. int r3,m=0;
  11. char r[2]={0};
  12.  
  13.  
  14.  
  15. void gotoxy(int x, int y)
  16. {
  17. HANDLE hCon;
  18. hCon = GetStdHandle(STD_OUTPUT_HANDLE);
  19.  
  20. COORD dwPos;
  21.  
  22. dwPos.X = x;
  23. dwPos.Y= y;
  24.  
  25. SetConsoleCursorPosition(hCon,dwPos);
  26. }
  27.  
  28.  
  29. struct salmunos
  30. {
  31.  int matricula;
  32.  char nom[15],pat[15],mat[15];
  33. }alum[10];
  34.  
  35. struct scalif
  36. {
  37.  int matricula;
  38.  char materia[20];
  39.  float corte1,corte2,corte3,prom;
  40. }calif[10];
  41.  
  42.  
  43. void registrar_alumnos()
  44. {
  45.  do
  46.   {
  47.    printf("\n\tAlumno: ");
  48.    scanf("%s", &alum[ca].nom);
  49.    printf("\n\tApeido Paterno: ");
  50.    scanf("%s", &alum[ca].pat);
  51.    printf("\n\tApeido Materno: ");
  52.    scanf("%s", &alum[ca].mat);
  53.    printf("\n\tMatricula: ");
  54.    scanf("%d", &alum[ca].matricula);
  55.    ca++;
  56.    system("cls");
  57.    gotoxy(5,0);printf("\n\tDesea almacenar mas datos? YES[1]/NO[2]: ");
  58.    scanf("%d",&resp);
  59.   }while(resp!=2);
  60.  
  61. }
  62.  
  63.  
  64. void mostrar_alumnos()
  65. {
  66.  printf("\n\nlista de Alumnos\n");
  67.  if (ca == 0)
  68.  {
  69.   printf("\n\tLista vacia..!");
  70.  }else
  71.      {
  72.       for(int i=0; i < ca; i++)
  73.       {
  74.       printf("\nAlumno: %s %s %s ",alum[i].nom, alum[i].pat, alum[i].mat);
  75.       printf("Matricula: %d\n\n",alum[i].matricula);
  76.    }
  77.  }
  78. }
  79.  
  80. void buscar_alumnos()
  81. {    
  82. int b = 0, c= 0;
  83. do
  84.   {
  85. printf("Ingrese matricula: ");
  86. scanf("%d", &buscar);
  87. for(int i = 0; i<ca; i++)
  88.     {
  89.      if(alum[i].matricula == buscar)
  90.       {
  91.   b = 1;
  92. c = i;
  93.         break;
  94.       }
  95.    }
  96. if(b == 1)
  97. {
  98. printf("\nEl nombre: %s", alum[c].nom);
  99.        printf("\nEl apellido paterno: %s", alum[c].pat);
  100.        printf("\nEl apellido materno: %s", alum[c].mat);
  101. }
  102. else
  103. {
  104. printf("Datos no encontrados");
  105. system("pause > null");
  106. }
  107.  printf("\nDesea salir? YES[1]/NO[2]: ");
  108.  scanf("%d",&resp);
  109.    }while(resp!=1);
  110.  }  
  111.  
  112. void eleminar_alumnos()
  113. {  
  114.  
  115.     do{
  116.                int b=0;            
  117.                system("cls");
  118.                printf("Ingrese la matricula: ");
  119.                scanf("%d",&m);
  120.                for(int y=0;y<10;y++)
  121.                {
  122.                 if(alum[y].matricula==m)
  123.                 {
  124.                 system("cls");
  125.                  printf("\nDatos a borrar...\n");
  126.                  printf("\nMatricula:%d",alum[y].matricula);
  127.                  printf("\nNombre:%s",&alum[y].nom);
  128.                  printf("\nApellido Paterno:%s",&alum[y].pat);
  129.                  printf("\nApellido Materno:%s\n",&alum[y].mat);                      
  130.                  printf("\nDeseas dar de baja?");
  131.                  scanf("%s",&r);
  132.                  if(strcmp(r,"si")==0)
  133.                  {          
  134.                    alum[y].matricula=alum[y+1].matricula;
  135.                    strcpy(alum[y].nom,alum[y+1].nom);
  136.                    strcpy(alum[y].pat,alum[y+1].pat);
  137.                    strcpy(alum[y].mat,alum[y+1].mat);
  138.                    ca--;
  139.                    alum[y].matricula=0;
  140.                    strcpy(alum[y].nom,"");
  141.                    strcpy(alum[y].pat,"");
  142.                    strcpy(alum[y].mat,"");
  143.                    printf("\nDatos Borrados...\n");  
  144.                   }
  145.                  }
  146.                   else
  147.                   {
  148.                    b++;  
  149.                       }
  150.                  }
  151.                  if(b==10)
  152.                  {
  153.                     printf("\nLa matricula ingresada no existe...\n");      
  154.                           }
  155.                   printf("\nDesea salir?");
  156.                   printf("\n[1]=SI");
  157.                   printf("\n[2]=NO\n");
  158.                   scanf("%d",&r3);                                      
  159.                }while(r3!=2);                                                              
  160.                system("pause");
  161.  
  162. }
  163. void modificar()
  164. {
  165. }                  
  166. void menu1()
  167. {
  168.     system("color 0F");
  169.     system("cls");
  170.     printf("\n\t\tREGISTRO DE ALMUNOS\n\n");
  171.     printf(" 1. Registrar \n");
  172.     printf(" 2. Mostrar registro de matriculas y almunos \n");
  173.     printf(" 3. Mostrar datos de un alumno \n");
  174.     printf(" 4. Modificar \n");
  175.     printf(" 5. Eliminar alumno del registro \n");
  176.     printf(" 6. Buscar nombre del alumno por matricula \n");
  177.     printf(" 7. Salir \n");
  178.  
  179.     printf("\n Ingrese opcion : ");
  180. }
  181.  
  182.  
  183. /*                      MAIN
  184. ------------------------------------------------------------------------------*/
  185.  
  186. int main()
  187. {
  188.  int op;
  189.  
  190.  do
  191.  {
  192.  menu1();
  193.  scanf("%d",&op);
  194.      switch(op)
  195.      {
  196.        case 1:
  197.               system("cls");
  198.               registrar_alumnos();
  199.  
  200.               break;
  201.        case 2:
  202.               system("cls");
  203.               mostrar_alumnos();
  204.               system("pause > NUL");
  205.               break;
  206.  
  207.  
  208.       case 5:
  209.              system("cls");
  210.              eleminar_alumnos();
  211.              printf("\n\n\t\tAlumno eliminado ..!");
  212.              system("pause > null");
  213.              break;
  214.  
  215.  
  216.        case 6:
  217.             system("cls");
  218.             buscar_alumnos();
  219.             system("pause > null");
  220.             break;
  221.  
  222.      }
  223.  
  224.  
  225.    } while(op!=7);
  226.  
  227.  return 0;  
  228. }


Título: Re: quien me ayude hacer el de modificar
Publicado por: engel lex en 6 Abril 2015, 02:50 am
que tal si empezamos agregando un poco al post... ej, que falta, que falla, que ayuda esperas recibir...
lectura obligatoria antes que publiques nada más...
10 pasos para plantear una duda informática (http://foro.elhacker.net/index.php/topic,159345.msg751417.html#msg751417)
FAQ : Como hacer preguntas "inteligentes" (http://foro.elhacker.net/index.php/topic,7122.0.html)