Ver Mensaje Individual
  #1 (permalink)  
Antiguo 07/12/2013, 02:04
likem4n
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Exclamación Ciclo While en funcion C

Hola que tal a quien se encuentre leyendo esto, soy algo novato en esto de la programacion y estoy realizando un programa tipo control escolar pero tengo un pequeño problema en uno de los bucles while exactamente en la funcion Numero 4, consulta_calificacion por alguna razon pregunta primero si quiera otra consulta, sin haber terminado la primera vuelta, este es el codigo, exactamente la funcion inicia en la linea de codigo numero 164.

Código C:
Ver original
  1. int n=0,ultimo;
  2.  
  3.  struct alumno {
  4.         char nombre[100][20];
  5.         char matricula[100][20];
  6.         char domicilio[100][20];
  7.         char telefono[100][20];
  8.         char fecha[100][20];
  9.         char especialidad[100][20];
  10.         char grupo[100][20];
  11.         int  calif[100][20];
  12.        };
  13.        struct alumno uno;
  14.  
  15.  captura(){ _setcursortype ( _NORMALCURSOR );
  16.  char frank='o';
  17.  
  18.   gotoxy(6,4);printf("Matricula        : ");
  19.   gotoxy(6,6);printf("Nombre           : ");
  20.   gotoxy(6,8);printf("Domicilio        : ");
  21.  gotoxy(6,10);printf("Telefono         : ");
  22.  gotoxy(6,12);printf("Fecha de ingreso : ");
  23.  gotoxy(6,14);printf("Especialidad     : ");
  24.  gotoxy(6,16);printf("Grupo            : ");
  25.  
  26.  do{
  27.  n=n+1;
  28.  ultimo=n;
  29.  
  30.   gotoxy(25,4);clreol();
  31.   gotoxy(25,6);clreol();
  32.   gotoxy(25,8);clreol();
  33.  gotoxy(25,10);clreol();
  34.  gotoxy(25,12);clreol();
  35.  gotoxy(25,14);clreol();
  36.  gotoxy(25,16);clreol();
  37.  
  38.  gotoxy(25,4);gets(uno.matricula[n]);
  39.  gotoxy(25,6);gets(uno.nombre[n]);
  40.  gotoxy(25,8);gets(uno.domicilio[n]);
  41.  gotoxy(25,10);gets(uno.telefono[n]);
  42.  gotoxy(25,12);gets(uno.fecha[n]);
  43.  gotoxy(25,14);gets(uno.especialidad[n]);
  44.  gotoxy(25,16);gets(uno.grupo[n]);
  45.  
  46.  gotoxy(6,24);printf("[O] Registrar otro alumno,");
  47.  gotoxy(6,25);printf("[TECLA CUALQUIERA] Continuar.");
  48.  frank=getche();
  49.  gotoxy(6,24);clreol();
  50.  gotoxy(6,25);clreol();
  51.  }while(frank=='o' || frank=='O');
  52.   }
  53.  
  54.  actualizacion(){
  55.  char matri[20];
  56.  char frank='r';
  57.  int bandera=1;
  58.  int x;
  59.  
  60.  while(frank=='r' || frank=='R'){
  61.  gotoxy(4,3);printf("Matricula: ");
  62.  gets(matri);
  63.  
  64.  for(x=1; x<=ultimo; x++){
  65.  
  66.  bandera=strcmp(uno.matricula[x],matri);
  67.  
  68.  if(bandera==0){
  69.   gotoxy(6,4);printf("Matricula        : ");
  70.   gotoxy(6,6);printf("Nombre           : ");
  71.   gotoxy(6,8);printf("Domicilio        : ");
  72.  gotoxy(6,10);printf("Telefono         : ");
  73.  gotoxy(6,12);printf("Fecha de ingreso : ");
  74.  gotoxy(6,14);printf("Especialidad     : ");
  75.  gotoxy(6,16);printf("Grupo            : ");
  76.  
  77.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  78.  gotoxy(25,6);printf("%s",uno.nombre[x]);
  79.  gotoxy(25,8);printf("%s",uno.domicilio[x]);
  80.  gotoxy(25,10);printf("%s",uno.telefono[x]);
  81.  gotoxy(25,12);printf("%s",uno.fecha[x]);
  82.  gotoxy(25,14);printf("%s",uno.especialidad[x]);
  83.  gotoxy(25,16);printf("%s",uno.grupo[x]);
  84.  
  85.  gotoxy(25,4);gets(uno.matricula[x]);
  86.  gotoxy(25,6);gets(uno.nombre[x]);
  87.  gotoxy(25,8);gets(uno.domicilio[x]);
  88.  gotoxy(25,10);gets(uno.telefono[x]);
  89.  gotoxy(25,12);gets(uno.fecha[x]);
  90.  gotoxy(25,14);gets(uno.especialidad[x]);
  91.  gotoxy(25,16);gets(uno.grupo[x]);
  92.  
  93.  }
  94.  
  95.  }
  96.  gotoxy(6,24);printf("[R] Otra actualizacion");
  97.  gotoxy(6,25);printf("[TECLA CUALQUIERA] Continuar.");
  98.  frank=getche();
  99.  clrscr();
  100.  }
  101.  }
  102.  
  103.  registro_calificaciones(){
  104.  char matri[20];
  105.  int bandera=1;
  106.  int x;
  107.  char frank='o';
  108.  
  109.  while(frank=='o' || frank=='O'){
  110.  
  111.  gotoxy(4,3);printf("Matricula: ");
  112.  gets(matri);
  113.  gotoxy(4,3);clreol();
  114.  
  115.  for(x=1; x<=ultimo; x++){
  116.  bandera=strcmp(uno.matricula[x],matri);
  117.  
  118.  if(bandera==0){
  119.   gotoxy(6,4);printf("Matricula        : ");
  120.   gotoxy(6,5);printf("Nombre           : ");
  121.   gotoxy(6,6);printf("Especialidad     : ");
  122.   gotoxy(6,7);printf("Grupo            : ");
  123.  
  124.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  125.  gotoxy(25,5);printf("%s",uno.nombre[x]);
  126.  gotoxy(25,6);printf("%s",uno.especialidad[x]);
  127.  gotoxy(25,7);printf("%s",uno.grupo[x]);
  128.  
  129.   gotoxy(6,12);printf("                       P1   P2   P3   CF ");
  130.   gotoxy(6,14);printf("Geometria Analitica : ");
  131.   gotoxy(6,16);printf("Estructura de Datos : ");
  132.   gotoxy(6,18);printf("HTML                : ");
  133.   gotoxy(6,20);printf("CTSyV II            : ");
  134.   gotoxy(6,22);printf("Biologia            : ");
  135.   gotoxy(6,24);printf("Ingles II           : ");
  136.  
  137.   gotoxy(29,14);printf("%i",uno.calif[x][1]);
  138.   gotoxy(29,16);printf("%i",uno.calif[x][2]);
  139.   gotoxy(29,18);printf("%i",uno.calif[x][3]);
  140.   gotoxy(29,20);printf("%i",uno.calif[x][4]);
  141.   gotoxy(29,22);printf("%i",uno.calif[x][5]);
  142.   gotoxy(29,24);printf("%i",uno.calif[x][6]);
  143.  
  144.   gotoxy(29,14);scanf("%i",&uno.calif[x][1]);
  145.   gotoxy(29,16);scanf("%i",&uno.calif[x][2]);
  146.   gotoxy(29,18);scanf("%i",&uno.calif[x][3]);
  147.   gotoxy(29,20);scanf("%i",&uno.calif[x][4]);
  148.   gotoxy(29,22);scanf("%i",&uno.calif[x][5]);
  149.   gotoxy(29,24);scanf("%i",&uno.calif[x][6]);
  150.  
  151.  }
  152.  
  153.  }
  154.  
  155.  
  156.  
  157.  gotoxy(6,27);printf("[O] Otro registro");
  158.  gotoxy(6,28);printf("[TECLA CUALQUIERA] Continuar.");
  159.  frank=getche();
  160.  clrscr();
  161.  }
  162.  }
  163.  
  164.  consulta_calificacion(){//ESTA ES LA FUNCION QUE ME GENERA EL PROBLEMA
  165.  char matri[20];
  166.  int bandera=1;
  167.  int x;
  168.  char bob='o';
  169.  
  170.  while(bob=='o' || bob=='O'){
  171.  
  172.  gotoxy(4,3);printf("Matricula: ");
  173.  gets(matri);
  174.  gotoxy(4,3);clreol();
  175.  
  176.  for(x=1; x<=ultimo; x++){
  177.  bandera=strcmp(uno.matricula[x],matri);
  178.  
  179.  if(bandera==0){
  180.   gotoxy(6,4);printf("Matricula        : ");
  181.   gotoxy(6,5);printf("Nombre           : ");
  182.   gotoxy(6,6);printf("Especialidad     : ");
  183.   gotoxy(6,7);printf("Grupo            : ");
  184.  
  185.  gotoxy(25,4);printf("%s",uno.matricula[x]);
  186.  gotoxy(25,5);printf("%s",uno.nombre[x]);
  187.  gotoxy(25,6);printf("%s",uno.especialidad[x]);
  188.  gotoxy(25,7);printf("%s",uno.grupo[x]);
  189.  
  190.   gotoxy(6,12);printf("                       P1   P2   P3   CF ");
  191.   gotoxy(6,14);printf("Geometria Analitica : ");
  192.   gotoxy(6,16);printf("Estructura de Datos : ");
  193.   gotoxy(6,18);printf("HTML                : ");
  194.   gotoxy(6,20);printf("CTSyV II            : ");
  195.   gotoxy(6,22);printf("Biologia            : ");
  196.   gotoxy(6,24);printf("Ingles II           : ");
  197.  
  198.   gotoxy(29,14);printf("%i",uno.calif[x][1]);
  199.   gotoxy(29,16);printf("%i",uno.calif[x][2]);
  200.   gotoxy(29,18);printf("%i",uno.calif[x][3]);
  201.   gotoxy(29,20);printf("%i",uno.calif[x][4]);
  202.   gotoxy(29,22);printf("%i",uno.calif[x][5]);
  203.   gotoxy(29,24);printf("%i",uno.calif[x][6]);
  204.  
  205.  }
  206.   }
  207.  gotoxy(6,27);printf("[O] Otra consulta");
  208.  gotoxy(6,28);printf("[TECLA CUALQUIERA] Continuar.");
  209.  bob=getche();
  210.  clrscr();
  211.  }
  212.   }
  213.  
  214.  impresion(){
  215.  
  216.  char nombre[20];
  217.  char matricula[20];
  218.  char domicilio[20];
  219.  char telefono[20];
  220.  char fecha[20];
  221.  char especialidad[20];
  222.  char grupo[20];
  223.  
  224.  int y, bandera1=0;
  225.  
  226.  textcolor(14);
  227.  gotoxy(2,3);cprintf(" Matricula        Nombre                           Telefono       Fecha Ingreso             Especialidad             Grupo");
  228.  for (int x=2; x<=124; x++){gotoxy(x,4);printf("="); }
  229.  
  230.  for(int y=1; y<=ultimo; y++){
  231.  gotoxy(3,6+y);printf("%s",uno.matricula[y]);
  232.  gotoxy(20,6+y);printf("%s",uno.nombre[y]);
  233.  gotoxy(53,6+y);printf("%s",uno.telefono[y]);
  234.  gotoxy(68,6+y);printf("%s",uno.fecha[y]);
  235.  gotoxy(94,6+y);printf("%s",uno.especialidad[y]);
  236.  gotoxy(120,6+y);printf("%s",uno.grupo[y]);
  237.  
  238.   }
  239.    }
  240.  
  241.  
  242.  main(){ _setcursortype ( _NOCURSOR );
  243.   char c;
  244.   char frank='s';
  245.  
  246.  while(frank=='s' || frank=='S'){
  247.  
  248.   textcolor(14);
  249.   gotoxy(12,4);cprintf("CONTROL ESCOLAR.");
  250.  
  251.    gotoxy(10,7);printf("1.- Alta de alumno.");
  252.    gotoxy(10,9);printf("2.- Mantenimiento.");
  253.   gotoxy(10,11);printf("3.- Registro de calificaciones.");
  254.   gotoxy(10,13);printf("4.- Consulta de calificaciones.");
  255.   gotoxy(10,15);printf("5.- Total de alumnos.");
  256.   gotoxy(10,17);printf("6.- Salir.");
  257.  
  258.   c=getche();
  259.    switch(c){
  260.  
  261.    case '1':
  262.    clrscr();
  263.    captura();
  264.    break;
  265.  
  266.    case '2':
  267.    clrscr();
  268.    actualizacion();
  269.    break;
  270.  
  271.    case '3':
  272.    clrscr();
  273.    registro_calificaciones();
  274.    break;
  275.  
  276.    case '4':
  277.    clrscr();
  278.    consulta_calificacion();
  279.    break;
  280.  
  281.    case '5':
  282.    clrscr();
  283.    impresion();
  284.    break;
  285.  
  286.    case '6':
  287.    clrscr();
  288.    return 0;
  289.    break;
  290.  
  291.    }//Cierre Switch - Case
  292.     gotoxy(6,24);printf("[S] Volver al menu");
  293.     gotoxy(6,25);printf("[TECLA CUALQUIERA] Salir.");
  294.     frank=getche();
  295.     clrscr();
  296.     }//cierre WHILE
  297.      }//Cierre MAIN

De antemano gracias, espero y puedan ayudarme a resolver mi problema, saludos.