Ver Mensaje Individual
  #5 (permalink)  
Antiguo 08/12/2013, 01:15
likem4n
 
Fecha de Ingreso: diciembre-2013
Mensajes: 10
Antigüedad: 10 años, 4 meses
Puntos: 0
Respuesta: Ciclo While en funcion C

Jejej en realidad esta completo solo faltan las librerias pero a continuacion lo cito, gracias de nuevo.

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