Advertisement
Jvsierra

trabson atp

Sep 21st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 37.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio2.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6.  
  7. #define TFI 100
  8. #define TFP 10
  9.  
  10. struct TpInscrito
  11. {
  12.     int Ins_Numero, Cod_Palestra1, Cod_Palestra2;
  13.     char Ins_Nome[30], Ins_Sexo, Ins_Cidade[30];
  14. };
  15.  
  16. struct TpPalestra
  17. {
  18.     int Pal_Codigo, Pal_TotVagas;
  19.     char Pal_Nome[40], Pal_Horario[6]; 
  20. };
  21.  
  22. struct TpEstatistica
  23. {
  24.     int Eve_Palestra, Eve_TotalInscritos, Eve_TotInscrFem, Eve_TotInscrMasc;   
  25.     float Eve_InscrVagas;
  26. };
  27.  
  28. int BuscaPalestra(TpPalestra Plst[TFP], int TL, int Chave)
  29. {
  30.     int i = 0;
  31.    
  32.     while(i < TL && Plst[i].Pal_Codigo != Chave)
  33.         i++;
  34.        
  35.     if(i < TL)
  36.         return i;
  37.     else
  38.         return -1;
  39. }
  40.  
  41. int BuscaInscritos(TpInscrito Insc[TFI], int TL, int Chave)
  42. {
  43.     int i = 0;
  44.    
  45.     while(i < TL && Insc[i].Ins_Numero != Chave)
  46.         i++;
  47.    
  48.     if(i < TL)
  49.         return i;
  50.     else
  51.         return -1;
  52. }
  53.  
  54. int BuscaEstatistica(TpEstatistica Est[TFP], int TL, int Chave)
  55. {
  56.     int i = 0;
  57.    
  58.     while(i < TL && Est[i].Eve_Palestra != Chave)
  59.         i++;
  60.        
  61.     if(i < TL)
  62.         return i;
  63.     else
  64.         return -1;
  65. }
  66.  
  67. int ValidaExclusao(TpInscrito Insc[TFI], int TLI, int CodPalestra)
  68. {
  69.     int i = 0;
  70.    
  71.     while(i < TLI && Insc[i].Cod_Palestra1 != CodPalestra && Insc[i].Cod_Palestra2 != CodPalestra)
  72.         i++;
  73.        
  74.     if(i == TLI)
  75.         return 1;
  76.     else
  77.         return -1;
  78. }
  79.  
  80. void meustrncpy(char str[40], char dest[40], int inicio, int fim)
  81. {
  82.     int i, pos = 0;
  83.    
  84.     strcpy(dest, "\0");
  85.    
  86.     for(i = inicio; i < fim; i++)
  87.         dest[pos++] = str[i];
  88.        
  89.     dest[pos] = '\0';
  90. }
  91.  
  92. int ProcuraInicio(char str[40], char chave[40], int n)
  93. {
  94.     int i = 0;
  95.    
  96.     while(i < n && toupper(str[i]) == toupper(chave[i]))
  97.         i++;
  98.        
  99.     if(i == n)
  100.         return 1;
  101.     else
  102.         return -1;
  103. }
  104.  
  105. int ProcuraMeio(char str[40], char chave[40])
  106. {
  107.     int i, inicio = 0, fim = strlen(chave);
  108.     char dest[40] = "\0";
  109.  
  110.     for(i = 0; fim < strlen(str) && stricmp(dest, chave) != 0; i++)
  111.         meustrncpy(str, dest, inicio++, fim++);
  112.        
  113.     if(i < strlen(str) && stricmp(dest, chave) == 0)
  114.         return 1;
  115.     else
  116.         return -1;
  117. }
  118.  
  119. void Quadro(int LI, int CI, int LF, int CF, int CorT, int corF)
  120. {
  121.     int i;
  122.    
  123.     textcolor(CorT);
  124.     textbackground(corF);
  125.    
  126.     gotoxy(CI, LI);
  127.     printf("%c", 201);
  128.    
  129.     gotoxy(CI, LF);
  130.     printf("%c", 200);
  131.    
  132.     gotoxy(CF, LI);
  133.     printf("%c", 187);
  134.    
  135.     gotoxy(CF, LF);
  136.    
  137.     printf("%c", 188);
  138.    
  139.     for(i = CI+1; i < CF; i++)
  140.     {
  141.         gotoxy(i, LI);
  142.         printf("%c", 205);
  143.     }
  144.    
  145.     for(i = LI + 1; i < LF; i++)
  146.     {
  147.         gotoxy(CI, i);
  148.         printf("%c", 186);
  149.         gotoxy(CF, i);
  150.         printf("%c", 186);
  151.     }
  152.    
  153.     for(i = CI + 1; i < CF; i++)
  154.     {
  155.         gotoxy(i, LF);
  156.         printf("%c", 205);
  157.     }
  158.    
  159.     textcolor(7);
  160.     textbackground(0);
  161. }
  162.  
  163. void QuadroSimples(int LI, int CI, int LF, int CF, int CorT, int corF)
  164. {
  165.         int i;
  166.    
  167.     textcolor(CorT);
  168.     textbackground(corF);
  169.    
  170.     gotoxy(CI, LI);
  171.     printf("%c", 218);
  172.    
  173.     gotoxy(CI, LF);
  174.     printf("%c", 192);
  175.    
  176.     gotoxy(CF, LI);
  177.     printf("%c", 191);
  178.    
  179.     gotoxy(CF, LF);
  180.    
  181.     printf("%c", 217);
  182.    
  183.     for(i = CI+1; i < CF; i++)
  184.     {
  185.         gotoxy(i, LI);
  186.         printf("%c", 196);
  187.     }
  188.    
  189.     for(i = LI + 1; i < LF; i++)
  190.     {
  191.         gotoxy(CI, i);
  192.         printf("%c", 179);
  193.         gotoxy(CF, i);
  194.         printf("%c", 179);
  195.     }
  196.    
  197.     for(i = CI + 1; i < CF; i++)
  198.     {
  199.         gotoxy(i, LF);
  200.         printf("%c", 196);
  201.     }
  202.    
  203.     textcolor(7);
  204.     textbackground(0);
  205. }
  206.  
  207. void CalculaEstatistica(TpEstatistica Est[TFP], TpPalestra Plst[TFP], int TLP, int Inicio, int Fim)
  208. {
  209.     int i;
  210.    
  211.     for(i = 0; i < Fim; i++)
  212.         Est[i].Eve_InscrVagas = (float)Est[i].Eve_TotalInscritos / Plst[BuscaPalestra(Plst, TLP, Est[i].Eve_Palestra)].Pal_TotVagas;
  213. }
  214.  
  215. void AtualizaEstatistica(TpEstatistica &Est1, TpEstatistica &Est2, char Sexo, int Tipo)
  216. {
  217.     /*
  218.     Tipo == 1 -> Inserir estatística
  219.     Tipo == 2 -> Remover estatística
  220.     Tipo == 3 -> Alterar sexo da estatística
  221.     Tipo == 4 -> "Swap" entre as estatísticas
  222.     */
  223.    
  224.     if(Tipo == 1)
  225.     {
  226.         Est1.Eve_TotalInscritos++;
  227.         Est2.Eve_TotalInscritos++;
  228.                
  229.         if(Sexo == 'M')
  230.         {
  231.             Est1.Eve_TotInscrMasc++;
  232.             Est2.Eve_TotInscrMasc++;
  233.         }
  234.         else
  235.         {
  236.             Est1.Eve_TotInscrFem++;
  237.             Est2.Eve_TotInscrFem++;
  238.         }
  239.     }
  240.     else if(Tipo == 2)
  241.     {
  242.         Est1.Eve_TotalInscritos--;
  243.         Est2.Eve_TotalInscritos--;
  244.        
  245.         if(Sexo == 'M')
  246.         {
  247.             Est1.Eve_TotInscrMasc--;
  248.             Est2.Eve_TotInscrMasc--;
  249.         }
  250.         else
  251.         {
  252.             Est1.Eve_TotInscrFem--;
  253.             Est2.Eve_TotInscrFem--;
  254.         }
  255.     }
  256.     else if(Tipo == 3)
  257.     {
  258.         if(Sexo == 'M')
  259.         {
  260.             Est1.Eve_TotInscrFem--;
  261.             Est1.Eve_TotInscrMasc++;
  262.            
  263.             Est2.Eve_TotInscrFem--;
  264.             Est2.Eve_TotInscrMasc++;
  265.         }
  266.         else
  267.         {
  268.             Est1.Eve_TotInscrFem++;
  269.             Est1.Eve_TotInscrMasc--;
  270.            
  271.             Est2.Eve_TotInscrFem++;
  272.             Est2.Eve_TotInscrMasc--;
  273.         }
  274.     }
  275.     else
  276.     {
  277.         Est1.Eve_InscrVagas--;
  278.         Est2.Eve_InscrVagas++;
  279.        
  280.         if(Sexo == 'M')
  281.         {
  282.             Est1.Eve_TotInscrMasc--;
  283.             Est2.Eve_TotInscrMasc++;
  284.         }
  285.         else
  286.         {
  287.             Est1.Eve_TotInscrFem--;
  288.             Est2.Eve_TotInscrMasc++;
  289.         }
  290.     }
  291. }
  292.  
  293. void OrdenaInscrito(TpInscrito Insc[TFI], int TLI)
  294. {
  295.     int i, j;
  296.     TpInscrito Aux;
  297.    
  298.     for(i = 0; i < TLI - 1; i++)
  299.         for(j = i + 1; j < TLI; j++)
  300.             if(stricmp(Insc[i].Ins_Nome, Insc[j].Ins_Nome) > 0)
  301.             {
  302.                 Aux = Insc[i];
  303.                 Insc[i] = Insc[j];
  304.                 Insc[j] = Aux;
  305.             }
  306. }
  307.  
  308. void OrdenaEstatistica(TpEstatistica Est[TFP], int TL)
  309. {
  310.     int i, j;
  311.     TpEstatistica Aux;
  312.    
  313.     for(i = 0; i < TL - 1; i++)
  314.         for(j = i + 1; j < TL; j++)
  315.         if(Est[i].Eve_InscrVagas < Est[j].Eve_InscrVagas)
  316.         {
  317.             Aux = Est[i];
  318.             Est[i] = Est[j];
  319.             Est[j] = Aux;
  320.         }
  321. }
  322.  
  323. void IncluiInscrito(TpInscrito Insc[TFI], int &TLI, TpPalestra Plst[TFP],
  324.     int TLP, TpEstatistica Est[TFP])
  325. {
  326.     int NumAux, Cont;
  327.    
  328.     system("cls");
  329.    
  330.     Quadro(1, 1, 25, 80, 2, 0);
  331.        
  332.     gotoxy(28, 2);
  333.     textcolor(15);
  334.     printf("Cadastro de Inscritos");
  335.    
  336.     if(TLP >= 2)
  337.     {
  338.        
  339.         Cont = 0;
  340.    
  341.         gotoxy(3, 4);
  342.         printf("Digite o numero do inscrito (0 para sair):");
  343.         scanf("%d", &NumAux);
  344.        
  345.         while(TLI < TFI && NumAux > 0)
  346.         {
  347.             if(BuscaInscritos(Insc, TLI, NumAux) >= 0)
  348.             {
  349.                 textbackground(7);
  350.                 textcolor(4);
  351.                 gotoxy(3, 5);
  352.                 printf("Numero do inscrito ja cadastrado\n");
  353.                 textcolor(7);
  354.                 textbackground(0);
  355.             }
  356.             else
  357.             {
  358.                
  359.                 Insc[TLI].Ins_Numero = NumAux;
  360.            
  361.                 gotoxy(3, 5);
  362.            
  363.                 printf("Nome do inscrito: ");
  364.                 fflush(stdin);
  365.                 gets(Insc[TLI].Ins_Nome);
  366.                
  367.                 while(strcmp(Insc[TLI].Ins_Nome, "\0") == 0)
  368.                 {
  369.                     gotoxy(3, 6);
  370.                     textcolor(4);
  371.                     printf("Digite um nome valido: ");
  372.                     fflush(stdin);
  373.                     textcolor(15);
  374.                     gets(Insc[TLI].Ins_Nome);
  375.                 }
  376.                
  377.                 gotoxy(3, 7);
  378.                 printf("Sexo: ");
  379.                 scanf("%c", &Insc[TLI].Ins_Sexo);
  380.                 Insc[TLI].Ins_Sexo = toupper(Insc[TLI].Ins_Sexo);
  381.                
  382.                 while(Insc[TLI].Ins_Sexo != 'M' && Insc[TLI].Ins_Sexo != 'F')
  383.                 {
  384.                     gotoxy(3, 8);
  385.                     textcolor(4);
  386.                     printf("Digite um dado valido:");
  387.                     fflush(stdin);
  388.                     textcolor(15);
  389.                     scanf("%c", &Insc[TLI].Ins_Sexo);
  390.                     Insc[TLI].Ins_Sexo = toupper(Insc[TLI].Ins_Sexo);
  391.                 }
  392.                
  393.                 gotoxy(3, 9);
  394.                
  395.                 printf("Cidade: ");
  396.                 fflush(stdin);
  397.                 gets(Insc[TLI].Ins_Cidade);
  398.                
  399.                 while(strcmp(Insc[TLI].Ins_Cidade, "\0") == 0)
  400.                 {
  401.                     textcolor(4);
  402.                     gotoxy(3, 10);
  403.                     printf("Digite uma cidade valida:");
  404.                     fflush(stdin);
  405.                     textcolor(15);
  406.                     gets(Insc[TLI].Ins_Cidade);
  407.                 }
  408.                
  409.                 gotoxy(3, 11);
  410.                
  411.                 printf("Codigo da primeira palestra: ");
  412.                 scanf("%d", &Insc[TLI].Cod_Palestra1);
  413.                
  414.                 while(BuscaPalestra(Plst, TLP, Insc[TLI].Cod_Palestra1) == -1)
  415.                 {
  416.                     gotoxy(3, 12);
  417.                     textcolor(4);
  418.                     printf("Codigo de palestra inexistente. Digite um codigo valido:  ");
  419.                     textcolor(15);
  420.                     scanf("%d", &Insc[TLI].Cod_Palestra1);
  421.                 }
  422.            
  423.                 gotoxy(3, 13);
  424.            
  425.                 printf("Codigo da segunda palestra: ");
  426.                 scanf("%d", &Insc[TLI].Cod_Palestra2); 
  427.                
  428.                 while(BuscaPalestra(Plst, TLP, Insc[TLI].Cod_Palestra2) == -1
  429.                      || Insc[TLI].Cod_Palestra1 == Insc[TLI].Cod_Palestra2)
  430.                 {
  431.                     gotoxy(3, 14);
  432.                     textcolor(4);
  433.                     printf("Codigo da palestra invalido. Digite um codigo valido:  ");
  434.                     textcolor(15);
  435.                     scanf("%d", &Insc[TLI].Cod_Palestra2);
  436.                 }
  437.                
  438.                 AtualizaEstatistica(Est[BuscaEstatistica(Est, TLP, Insc[TLI].Cod_Palestra1)],
  439.                                     Est[BuscaEstatistica(Est, TLP, Insc[TLI].Cod_Palestra2)],
  440.                                     Insc[TLI].Ins_Sexo, 1);
  441.                
  442.                 TLI++;
  443.                
  444.                 Cont++;
  445.    
  446.                 textcolor(2);
  447.                
  448.                 gotoxy(30, 15);
  449.                
  450.                 printf("Inscrito cadastrado");
  451.             }
  452.            
  453.             getch();
  454.            
  455.             system("cls");
  456.            
  457.             Quadro(1, 1, 25, 80, 2, 0);
  458.        
  459.             gotoxy(28, 2);
  460.             textcolor(WHITE);
  461.             printf("Cadastro de Inscritos");
  462.            
  463.             gotoxy(3, 4);
  464.             printf("Digite o numero do inscrito (0 para sair):");
  465.             scanf("%d", &NumAux);
  466.         }
  467.        
  468.         CalculaEstatistica(Est, Plst, TLP, TLI - Cont, TLI);
  469.         OrdenaEstatistica(Est, TLP);
  470.         OrdenaInscrito(Insc, TLI);
  471.     }
  472.     else
  473.     {
  474.         gotoxy(22, 3);
  475.         textbackground(WHITE);
  476.         textcolor(4);
  477.         printf(" Nao ha palestras suficientes! ");
  478.         textcolor(15);
  479.         textbackground(0);
  480.     }
  481.    
  482.     getch();
  483. }
  484.  
  485. void RemoveInscrito(TpInscrito Insc[TFI], int &TLI, TpPalestra Plst[TFP],
  486.     int TLP, TpEstatistica Est[TFP])
  487. {
  488.     int NumeroAux, Pos, i, PosEst, Cont;
  489.    
  490.     system("cls");
  491.    
  492.     Quadro(1, 1, 25, 80, 2, 0);
  493.  
  494.     textcolor(15);
  495.    
  496.     gotoxy(30, 2);
  497.  
  498.     printf("Exclusao de inscritos");
  499.    
  500.     if(TLI == 0)
  501.     {
  502.         gotoxy(27,3);
  503.         textcolor(4);
  504.         printf("Nenhum inscrito cadastrado");
  505.         textcolor(15);
  506.     }
  507.     else
  508.     {
  509.         gotoxy(3, 4);
  510.         printf("Digite o numero do inscrito (0 para sair): ");
  511.         scanf("%d", &NumeroAux);
  512.        
  513.         while(NumeroAux > 0)
  514.         {
  515.             Cont = 0;
  516.            
  517.             Pos = BuscaInscritos(Insc, TLI, NumeroAux);
  518.            
  519.             if(Pos == -1)
  520.             {
  521.                 gotoxy(3, 5);
  522.                 textcolor(4);
  523.                 printf("Nenhum inscrito com esse numero");
  524.                 textcolor(15);
  525.             }
  526.             else
  527.             {
  528.                 gotoxy(3, 6);
  529.                 textcolor(10);
  530.                 printf("Confirma exclusao? (S/N): ");
  531.                
  532.                 if(toupper(getch()) == 'S')
  533.                 {
  534.                     AtualizaEstatistica(Est[BuscaEstatistica(Est, TLP, Insc[Pos].Cod_Palestra1)],
  535.                                         Est[BuscaEstatistica(Est, TLP, Insc[Pos].Cod_Palestra2)],
  536.                                         Insc[Pos].Ins_Sexo, 2);
  537.    
  538.                     CalculaEstatistica(Est, Plst, TLP, 0, TLP);
  539.    
  540.                     for(; Pos < TLI - 1; Pos++)
  541.                         Insc[Pos] = Insc[Pos + 1];
  542.                        
  543.                     TLI--;
  544.                    
  545.                     gotoxy(3, 7);
  546.                    
  547.                     textcolor(10);
  548.                     printf("Inscrito excluido");
  549.                 }
  550.                 else
  551.                 {
  552.                     gotoxy(20, 7);
  553.                     textcolor(11);
  554.                     printf("Exclusao cancelada");
  555.                     textcolor(15);
  556.                 }
  557.             }
  558.            
  559.             getch();
  560.            
  561.             system("cls");
  562.            
  563.             Quadro(1, 1, 25, 80, 2, 0);
  564.            
  565.             gotoxy(30, 2);
  566.  
  567.             textcolor(15);
  568.  
  569.             printf("Exclusao de inscritos");
  570.            
  571.             gotoxy(3, 4);
  572.             printf("Digite o numero do inscrito (0 para sair): ");
  573.             scanf("%d", &NumeroAux);
  574.         }
  575.        
  576.     }
  577.    
  578.     getch();
  579. }
  580.  
  581. char MenuAlteraInscrito(void)
  582. {
  583.     gotoxy(3, 4);
  584.     printf("Escolha:");
  585.     gotoxy(3, 5);
  586.     printf("[A] - Alterar nome");
  587.     gotoxy(3, 6);
  588.     printf("[B] - Alterar sexo\n");
  589.     gotoxy(3, 7);
  590.     printf("[C] - Alterar cidade");
  591.     gotoxy(3, 8);
  592.     printf("[D] - Alterar codigo da primeira palestra");
  593.     gotoxy(3, 9);
  594.     printf("[E] - Alterar codigo da segunda palestra");
  595.     gotoxy(3, 10);
  596.     printf("[ESC] - Sair ");
  597.    
  598.     return toupper(getche());
  599. }
  600.  
  601. void AlteraInscrito(TpInscrito Insc[TFI], int TLI, TpPalestra Plst[TFP], int TLP,
  602.     TpEstatistica Est[TFP])
  603. {
  604.     int Pos, NumAux, PalAux;
  605.     char Op, AuxS;
  606.    
  607.     system("cls");
  608.    
  609.     Quadro(1, 1, 25, 80, 2, 0);
  610.  
  611.     textcolor(15);
  612.    
  613.     gotoxy(30, 2);
  614.  
  615.     printf("Alteracao de inscritos");
  616.    
  617.     if(TLI == 0)
  618.     {
  619.         gotoxy(27, 3);
  620.         textcolor(4);
  621.         printf("Nenhum inscrito cadastrado");
  622.         textcolor(15);
  623.     }
  624.     else
  625.     {
  626.         gotoxy(3, 3);
  627.         printf("Digite o numero do inscrito (0 para sair): ");
  628.         scanf("%d", &NumAux);
  629.        
  630.         while(NumAux > 0)
  631.         {
  632.             Pos = BuscaInscritos(Insc, TLI, NumAux);
  633.            
  634.             if(Pos == -1)
  635.             {
  636.                 gotoxy(3, 4);
  637.                 textcolor(4);
  638.                 printf("Nenhum inscrito com esse numero\n");
  639.             }
  640.             else
  641.             {
  642.                
  643.                 Op = MenuAlteraInscrito();
  644.                
  645.                 while(Op != 27)
  646.                 {
  647.                     gotoxy(3, 11);
  648.                     switch(Op)
  649.                     {
  650.                         case 'A':
  651.                             printf("Nome atual: %s ", Insc[Pos].Ins_Nome);
  652.                            
  653.                             gotoxy(3, 12);
  654.                            
  655.                             printf("Digite o novo nome: ");
  656.                             fflush(stdin);
  657.                             gets(Insc[Pos].Ins_Nome);
  658.                            
  659.                             while(strcmp(Insc[Pos].Ins_Nome, "\0") == 0)
  660.                             {
  661.                                 textcolor(4);
  662.                                 gotoxy(3, 13);
  663.                                 printf("Nome invalido.");
  664.                                 textcolor(15);
  665.                                 gotoxy(3, 14);
  666.                                 printf("Digite o novo nome: ");
  667.                                 fflush(stdin);
  668.                                 gets(Insc[Pos].Ins_Nome);
  669.                             }
  670.                            
  671.                             gotoxy(3, 15);
  672.                             printf("Nome alterado");
  673.                         break;
  674.                         case 'B':
  675.                             printf("Sexo atual: %c ", Insc[Pos].Ins_Sexo);
  676.                            
  677.                             gotoxy(3, 12);
  678.                             printf("Digite o novo sexo(F/M):");
  679.                             fflush(stdin);
  680.                             scanf("%c", &AuxS);
  681.                             AuxS = toupper(AuxS);
  682.                            
  683.                             while(AuxS != 'M' && AuxS != 'F')
  684.                             {
  685.                                 textcolor(4);
  686.                                 gotoxy(3, 13);
  687.                                 printf("Sexo invalido. Digite um caractere valido:");
  688.                                 textcolor(15);
  689.                                 fflush(stdin);
  690.                                 scanf("%c", &AuxS);
  691.                                 AuxS = toupper(AuxS);
  692.                             }
  693.                            
  694.                             //Atualizando as estatísticas por sexo das palestras do inscrito
  695.                             AtualizaEstatistica(Est[BuscaEstatistica(Est, TLP, Insc[Pos].Cod_Palestra1)],
  696.                                                 Est[BuscaEstatistica(Est, TLP, Insc[Pos].Cod_Palestra2)],
  697.                                                 AuxS, 3);
  698.                                
  699.                             Insc[Pos].Ins_Sexo = AuxS;
  700.                            
  701.                             gotoxy(3, 15);
  702.                            
  703.                             printf("Sexo alterado");
  704.                         break;
  705.                         case 'C':
  706.                             printf("Cidade atual: %s", Insc[Pos].Ins_Cidade);
  707.                            
  708.                             gotoxy(3, 12);
  709.                            
  710.                             printf("Digite a nova cidade:");
  711.                             fflush(stdin);
  712.                             gets(Insc[Pos].Ins_Cidade);
  713.                            
  714.                             while(strcmp(Insc[Pos].Ins_Cidade, "\0") == 0)
  715.                             {
  716.                                 gotoxy(3, 13);
  717.                                 textcolor(4);
  718.                                 printf("Dado invalido. Digite a nova cidade: ");
  719.                                 textcolor(15);
  720.                                 fflush(stdin);
  721.                                 gets(Insc[Pos].Ins_Cidade);
  722.                             }
  723.                            
  724.                             gotoxy(3, 15);
  725.                            
  726.                             printf("Cidade alterada");
  727.                         break;
  728.                         case 'D':
  729.                             printf("Codigo atual: %d", Insc[Pos].Cod_Palestra1);
  730.                            
  731.                             gotoxy(3, 12);
  732.                             printf("Digite o novo codigo da primeira palestra: ");
  733.                             scanf("%d", &PalAux);
  734.                            
  735.                             while(BuscaPalestra(Plst, TLP, PalAux) == - 1 ||
  736.                                  PalAux == Insc[Pos].Cod_Palestra2)
  737.                             {
  738.                                 gotoxy(3, 13);
  739.                                 textcolor(4);
  740.                                 printf("Codigo de palestra invalido. Digite um codigo valido:");
  741.                                 textcolor(15);
  742.                                 scanf("%d", &PalAux);      
  743.                             }
  744.                            
  745.                             AtualizaEstatistica(Est[BuscaEstatistica(Est, TLP, PalAux)],
  746.                                                 Est[BuscaEstatistica(Est, TLP, Insc[Pos].Cod_Palestra1)],
  747.                                                  Insc[Pos].Ins_Sexo, 4);
  748.                                                  
  749.                             Insc[Pos].Cod_Palestra1 = PalAux;
  750.                            
  751.                             gotoxy(3, 15);     
  752.                                                
  753.                             printf("Codigo da primeira palestra alterado");
  754.                         break;
  755.                         case 'E':
  756.                             printf("Codigo atual: %d", Insc[Pos].Cod_Palestra2);
  757.                            
  758.                             gotoxy(3, 12);
  759.                            
  760.                             printf("Digite o novo codigo da segunda palestra:");
  761.                             scanf("%d", &PalAux);
  762.                            
  763.                             while(BuscaPalestra(Plst, TLP, PalAux) == - 1 ||
  764.                                  PalAux == Insc[Pos].Cod_Palestra1)
  765.                             {
  766.                                 gotoxy(3, 13);
  767.                                 textcolor(4);
  768.                                 printf("Codigo de palestra invalido. Digite o novo codigo da segunda palestra: ");
  769.                                 textcolor(15);
  770.                                 scanf("%d", &PalAux);      
  771.                             }
  772.                            
  773.                             AtualizaEstatistica(Est[BuscaEstatistica(Est, TLP, PalAux)],
  774.                                                 Est[BuscaEstatistica(Est, TLP, Insc[Pos].Cod_Palestra2)],
  775.                                                  Insc[Pos].Ins_Sexo, 4);
  776.                                                  
  777.                             Insc[Pos].Cod_Palestra2 = PalAux;
  778.                                                
  779.                             gotoxy(3, 15);     
  780.                             printf("Codigo da segunda palestra alterado");
  781.                         break;
  782.                         default:
  783.                             gotoxy(20, 16);
  784.                             textcolor(4);
  785.                             printf("Opcao invalida");
  786.                             textcolor(15);
  787.                         break;
  788.                     }
  789.                    
  790.                     getch();
  791.                    
  792.                     system("cls");
  793.                    
  794.                     Quadro(1, 1, 25, 80, 2, 0);
  795.                
  796.                     textcolor(15);
  797.                    
  798.                     gotoxy(30, 2);
  799.                
  800.                     printf("Alteracao de inscritos");
  801.                    
  802.                     Op = MenuAlteraInscrito();
  803.                 }
  804.             }
  805.            
  806.             getch();
  807.            
  808.             system("cls");
  809.    
  810.             Quadro(1, 1, 25, 80, 2, 0);
  811.        
  812.             textcolor(15);
  813.            
  814.             gotoxy(30, 2);
  815.        
  816.             printf("Alteracao de inscritos");
  817.            
  818.             gotoxy(3, 3);
  819.            
  820.             printf("Digite o numero do inscrito (0 para sair): ");
  821.             scanf("%d", &NumAux);
  822.         }
  823.        
  824.         OrdenaInscrito(Insc, TLI);
  825.     }
  826.    
  827.     getch();
  828. }
  829.  
  830. void ImprimeInscrito(TpInscrito Insc, TpPalestra Plst[TFP], int TLP, int linha)
  831. {
  832.     Quadro(linha - 1, 2, linha + 3, 79, 15, 0);
  833.     textcolor(15);
  834.     gotoxy(3,linha);
  835.     printf("%s", Insc.Ins_Nome);
  836.     gotoxy(44,linha);
  837.     printf("Sexo:%c", Insc.Ins_Sexo);
  838.     gotoxy(51,linha++);
  839.     printf("%s", Insc.Ins_Cidade);
  840.     gotoxy(3,linha++);
  841.     printf("Primeira palestra: %s", Plst[BuscaPalestra(Plst, TLP, Insc.Cod_Palestra1)].Pal_Nome);
  842.     gotoxy(3,linha);
  843.     printf("Segunda palestra: %s", Plst[BuscaPalestra(Plst, TLP, Insc.Cod_Palestra2)].Pal_Nome);
  844. }
  845.  
  846. void ConsultaInscrito(TpInscrito Insc[TFI], int TLI, TpPalestra Plst[TFP], int TLP)
  847. {
  848.     int NumAux, Pos;
  849.    
  850.     system("cls");
  851.        
  852.     Quadro(1, 1, 25, 80, 2, 0);
  853.    
  854.     textcolor(15);
  855.        
  856.     gotoxy(30, 2);
  857.    
  858.     printf("Consulta de de inscritos");
  859.    
  860.     if(TLI == 0)
  861.     {
  862.         textcolor(4);
  863.         gotoxy(29,3);
  864.         printf("Nenhum inscrito cadastrado");
  865.         textcolor(15);
  866.     }
  867.     else
  868.     {
  869.         gotoxy(3, 3);
  870.         printf("Digite o numero do inscrito (0 para sair): ");
  871.         scanf("%d", &NumAux);
  872.        
  873.         while(NumAux > 0)
  874.         {
  875.             Pos = BuscaInscritos(Insc, TLI, NumAux);
  876.            
  877.             if(Pos == -1)
  878.             {
  879.                 gotoxy(3, 4);
  880.                 textcolor(4);
  881.                 printf("Nenhum inscrito com esse numero!");
  882.                 textcolor(15);
  883.             }
  884.             else
  885.                 ImprimeInscrito(Insc[Pos], Plst, TLP, 5);
  886.  
  887.  
  888.             getch();
  889.            
  890.             system("cls");
  891.                        
  892.             Quadro(1, 1, 25, 80, 2, 0);
  893.            
  894.             textcolor(15);
  895.                
  896.             gotoxy(30, 2);
  897.            
  898.             printf("Consulta de de inscritos");
  899.  
  900.             gotoxy(3, 3);
  901.             printf("Digite o numero do inscrito (0 para sair): ");
  902.             scanf("%d", &NumAux);  
  903.         }
  904.     }
  905.    
  906.     getch();
  907. }
  908.  
  909. void ListaInscritos(TpInscrito Insc[TFI], int TLI, TpPalestra Plst[TFP], int TLP)
  910. {
  911.     int i, linha = 2;
  912.    
  913.     system("cls");
  914.    
  915.     if(TLI == 0)
  916.     {
  917.         gotoxy(27, 2);
  918.         textcolor(4);
  919.         printf("Nenhum inscrito cadastrado\n\n");
  920.         textcolor(15);
  921.     }
  922.     else
  923.     {
  924.         textcolor(15);
  925.        
  926.         for(i = 0; i < TLI; i++)
  927.         {
  928.             ImprimeInscrito(Insc[i], Plst, TLP, linha);
  929.             linha+=5;
  930.         }
  931.        
  932.         gotoxy(1, 1);
  933.        
  934.         textbackground(0);
  935.     }
  936.    
  937.     getch();
  938. }
  939.  
  940. void OrdenaPalestra(TpPalestra Plst[TFP], int TLP)
  941. {
  942.     int i, j;
  943.     TpPalestra Aux;
  944.    
  945.     for(i = 0; i < TLP - 1; i++)
  946.         for(j = i + 1; j < TLP; j++)
  947.         if(strcmp(Plst[i].Pal_Nome, Plst[j].Pal_Nome) > 0)
  948.         {
  949.             Aux = Plst[i];
  950.             Plst[i] = Plst[j];
  951.             Plst[j] = Aux;
  952.         }
  953. }
  954.  
  955. void IncluiPalestra(TpPalestra Plst[TFP], int &TL, TpEstatistica Est[TFP])
  956. {
  957.     int CodigoAux;
  958.    
  959.     system("cls");
  960.        
  961.     Quadro(1, 1, 25, 80, 2, 0);
  962.    
  963.     textcolor(15);
  964.        
  965.     gotoxy(30, 2);
  966.    
  967.     printf("Cadastro de Palestras");
  968.    
  969.     gotoxy(3, 3);
  970.    
  971.     printf("Codigo da palestra (0 para sair):");
  972.     scanf("%d", &CodigoAux);
  973.    
  974.     while(TL < TFP && CodigoAux > 0)
  975.     {
  976.         if(BuscaPalestra(Plst, TL, CodigoAux) >= 0)
  977.         {
  978.             textcolor(4);
  979.             gotoxy(3,4);
  980.             printf("Codigo de palestra ja cadastrado!");
  981.             textcolor(15);
  982.         }
  983.         else
  984.         {
  985.             Plst[TL].Pal_Codigo = CodigoAux;
  986.            
  987.             gotoxy(3, 4);
  988.             printf("Nome da palestra:");
  989.             fflush(stdin);
  990.             gets(Plst[TL].Pal_Nome);
  991.            
  992.             while(strcmp(Plst[TL].Pal_Nome, "\0") == 0)
  993.             {
  994.                 gotoxy(3, 5);
  995.                 textcolor(4);
  996.                 printf("Digite um nome valido:");
  997.                 textcolor(15);
  998.                 fflush(stdin);
  999.                 gets(Plst[TL].Pal_Nome);
  1000.             }
  1001.            
  1002.             gotoxy(3, 6);
  1003.             printf("Horario da palestra (hh:mm):");
  1004.             fflush(stdin);
  1005.             gets(Plst[TL].Pal_Horario);
  1006.            
  1007.             while(strcmp(Plst[TL].Pal_Horario, "") == 0)
  1008.             {
  1009.                 gotoxy(3, 7);
  1010.                 textcolor(4);
  1011.                 printf("Digite um horario valido:");
  1012.                 textcolor(15);
  1013.                 gets(Plst[TL].Pal_Horario);
  1014.             }
  1015.            
  1016.             gotoxy(3, 8);
  1017.            
  1018.             printf("Total de vagas:");
  1019.             scanf("%d", &Plst[TL].Pal_TotVagas);
  1020.            
  1021.             while(Plst[TL].Pal_TotVagas < 1)
  1022.             {
  1023.                 gotoxy(3, 9);
  1024.                 textcolor(4);
  1025.                 printf("Digite um total de vagas valido:");
  1026.                 textcolor(15);
  1027.                 scanf("%d", &Plst[TL].Pal_TotVagas);
  1028.             }
  1029.            
  1030.             Est[TL].Eve_Palestra = Plst[TL].Pal_Codigo;
  1031.             Est[TL].Eve_TotalInscritos = 0;
  1032.            
  1033.             TL++;
  1034.            
  1035.             gotoxy(3, 10);
  1036.            
  1037.             textcolor(10);
  1038.             printf("Palestra cadastrada!");
  1039.         }
  1040.        
  1041.         getch();
  1042.        
  1043.         system("cls");
  1044.        
  1045.         Quadro(1, 1, 25, 80, 2, 0);
  1046.        
  1047.         textcolor(15);
  1048.            
  1049.         gotoxy(30, 2);
  1050.        
  1051.         printf("Cadastro de Palestras");
  1052.        
  1053.         gotoxy(3, 3);
  1054.        
  1055.         printf("Codigo da palestra (0 para sair):");
  1056.         scanf("%d", &CodigoAux);
  1057.     }
  1058.    
  1059.     OrdenaPalestra(Plst, TL);
  1060.    
  1061.     getch();
  1062. }
  1063.  
  1064. void CabecalhoPalestras(void)
  1065. {  
  1066.     QuadroSimples(1, 1, 3, 10, 15, 0);
  1067.     QuadroSimples(1, 11, 3, 58, 15, 0);
  1068.     QuadroSimples(1, 59, 3, 69, 15, 0);
  1069.     QuadroSimples(1, 70, 3, 77, 15, 0);
  1070.    
  1071.     textcolor(15);
  1072.    
  1073.     gotoxy(2, 2);
  1074.     printf("Codigo");
  1075.     gotoxy(12, 2);
  1076.     printf("Nome da Palestra");
  1077.     gotoxy(60, 2);
  1078.     printf("Horario");
  1079.     gotoxy(71, 2);
  1080.     printf("Vagas");
  1081. }
  1082.  
  1083. void ImprimePalestra(TpPalestra Plst, int linha)
  1084. {
  1085.     QuadroSimples(linha, 1,  linha+2, 10, 15, 0);
  1086.     QuadroSimples(linha, 11, linha+2, 58, 15, 0);
  1087.     QuadroSimples(linha, 59, linha+2, 69, 15, 0);
  1088.     QuadroSimples(linha, 70, linha+2, 77, 15, 0);
  1089.    
  1090.     textcolor(15);
  1091.    
  1092.     gotoxy(2, linha+1);
  1093.     printf("%d", Plst.Pal_Codigo);
  1094.    
  1095.     gotoxy(12, linha+1);
  1096.     printf("%s", Plst.Pal_Nome);
  1097.    
  1098.     gotoxy(60, linha+1);
  1099.     printf("%s", Plst.Pal_Horario);
  1100.    
  1101.     gotoxy(71, linha+1);
  1102.     printf("%d", Plst.Pal_TotVagas);
  1103. }
  1104.  
  1105. void ListaPalestras(TpPalestra Plst[TFP], int TLP)
  1106. {
  1107.     int i, linha = 4;
  1108.    
  1109.     system("cls");
  1110.    
  1111.     textcolor(15);
  1112.    
  1113.     if(TLP == 0)
  1114.     {  
  1115.         textcolor(4);
  1116.         gotoxy(27, 2);
  1117.         printf("Nenhuma palestra cadastrada!");
  1118.         textcolor(15);
  1119.     }
  1120.     else
  1121.     {
  1122.         textbackground(4);
  1123.         textcolor(14);
  1124.        
  1125.         CabecalhoPalestras();
  1126.        
  1127.         for(i = 0; i < TLP; i++)
  1128.         {
  1129.             ImprimePalestra(Plst[i], linha);
  1130.             linha+=3;
  1131.         }
  1132.        
  1133.         linha = 4;
  1134.        
  1135.         gotoxy(1, 1);
  1136.        
  1137.         textbackground(0);
  1138.     }
  1139.    
  1140.     getch();
  1141. }
  1142.  
  1143. void ConsultaPalestras(TpPalestra Plst[TFP], int TLP)
  1144. {
  1145.     int CodAux, Pos;
  1146.    
  1147.     system("cls");
  1148.    
  1149.     Quadro(1, 1, 25, 80, 2, 0);
  1150.    
  1151.     gotoxy(20,2);
  1152.    
  1153.     textcolor(15);
  1154.    
  1155.     printf("Consulta de palestras");
  1156.    
  1157.     if(TLP == 0)
  1158.     {
  1159.         gotoxy(20,4);
  1160.         textcolor(4);
  1161.         printf("Nenhuma palestra cadastrada");
  1162.         textcolor(15);
  1163.     }
  1164.     else
  1165.     {
  1166.         gotoxy(3, 3);
  1167.    
  1168.         printf("Codigo da palestra (0 para sair):");
  1169.         scanf("%d", &CodAux);
  1170.        
  1171.         while(CodAux > 0)
  1172.         {
  1173.             Pos = BuscaPalestra(Plst, TLP, CodAux);
  1174.            
  1175.             if(Pos == -1)
  1176.             {
  1177.                 gotoxy(3,5);
  1178.                 textcolor(4);
  1179.                 printf("Nenhuma palestra com esse codigo");
  1180.                 textcolor(15);
  1181.             }
  1182.             else
  1183.             {
  1184.                 system("cls");
  1185.                 CabecalhoPalestras();
  1186.                
  1187.                 ImprimePalestra(Plst[Pos], 4);
  1188.             }
  1189.                
  1190.             getch();   
  1191.            
  1192.             system("cls");
  1193.            
  1194.             Quadro(1, 1, 25, 80, 2, 0);
  1195.    
  1196.             gotoxy(20,2);
  1197.    
  1198.             textcolor(15);
  1199.    
  1200.             printf("Consulta de palestras");
  1201.        
  1202.             gotoxy(3, 3);
  1203.            
  1204.             printf("Codigo da palestra (0 para sair):");
  1205.             scanf("%d", &CodAux);
  1206.         }
  1207.     }
  1208.    
  1209.     textbackground(0);
  1210.    
  1211.     getch();
  1212. }
  1213.  
  1214. void ExcluiPalestra(TpPalestra Plst[TFP], TpInscrito Insc[TFI],
  1215.     int TLI, TpEstatistica Est[TFP], int &TLP)
  1216. {
  1217.     int CodAux, Pos;
  1218.    
  1219.     system("cls");
  1220.    
  1221.     Quadro(1, 1, 25, 80, 2, 0);
  1222.    
  1223.     gotoxy(27,2);
  1224.    
  1225.     textcolor(15);
  1226.    
  1227.     printf("Exclusao de palestras");
  1228.    
  1229.     if(TLP == 0)
  1230.     {
  1231.         gotoxy(25,3);
  1232.         textcolor(4);
  1233.         printf("Nenhum palestra cadastrada");
  1234.         textcolor(15);
  1235.     }
  1236.     else
  1237.     {
  1238.         gotoxy(3, 3);
  1239.         printf("Digite o codigo da palestra (0 para sair):");
  1240.         scanf("%d", &CodAux);
  1241.        
  1242.         while(CodAux > 0)
  1243.         {
  1244.             Pos = BuscaPalestra(Plst, TLP, CodAux);
  1245.            
  1246.             if(Pos == -1)
  1247.             {
  1248.                 gotoxy(3, 4);
  1249.                 textcolor(4);
  1250.                 printf("Nenhuma palestra com esse codigo");
  1251.                 textcolor(15);
  1252.             }
  1253.             else
  1254.             {
  1255.                 if(ValidaExclusao(Insc, TLI, Plst[Pos].Pal_Codigo) == -1)
  1256.                 {
  1257.                     textcolor(4);
  1258.                     gotoxy(3, 4);
  1259.                     printf("Palestra tem inscritos cadastrados");
  1260.                     textcolor(15);
  1261.                 }  
  1262.                 else
  1263.                 {
  1264.                     gotoxy(3, 5);
  1265.                     textcolor(10);
  1266.                     printf("Confirma exclusao? (S/N):");
  1267.                    
  1268.                     if(toupper(getch()) == 'S')
  1269.                     {
  1270.                         for(;Pos < TLP - 1; Pos++)
  1271.                         {
  1272.                             Plst[Pos] = Plst[Pos + 1];
  1273.                             Est[Pos] = Est[Pos + 1];
  1274.                         }
  1275.                            
  1276.                         TLP--;
  1277.                        
  1278.                         gotoxy(3, 6);
  1279.                        
  1280.                         printf("Palestra excluida");
  1281.                     }
  1282.                     else
  1283.                     {
  1284.                         gotoxy(3, 6);
  1285.                         printf("Exclusao cancelada");  
  1286.                     }
  1287.                    
  1288.                     textcolor(15);
  1289.                 }
  1290.             }
  1291.            
  1292.             getch();
  1293.            
  1294.             system("cls");
  1295.            
  1296.             Quadro(1, 1, 25, 80, 2, 0);
  1297.            
  1298.             gotoxy(27,2);
  1299.            
  1300.             textcolor(15);
  1301.            
  1302.             printf("Exclusao de palestras");
  1303.            
  1304.             gotoxy(3, 3);
  1305.             printf("Digite o codigo da palestra (0 para sair):");
  1306.             scanf("%d", &CodAux);
  1307.         }
  1308.     }
  1309.    
  1310.     getch();
  1311. }
  1312.  
  1313. char MenuAlteraPalestra(void)
  1314. {
  1315.     gotoxy(3, 4);
  1316.     printf("Escolha:");
  1317.     gotoxy(3, 5);
  1318.     printf("[A] - Alterar nome");
  1319.     gotoxy(3, 6);
  1320.     printf("[B] - Alterar horario");
  1321.     gotoxy(3, 7);
  1322.     printf("[C] - Alterar numero de vagas");
  1323.     gotoxy(3, 8);
  1324.     printf("[ESC] - Sair");
  1325.    
  1326.     return toupper(getch());
  1327. }
  1328.  
  1329. void AlteraPalestra(TpPalestra Plst[TFP], int TLP)
  1330. {
  1331.     int CodAux, Pos;
  1332.     char Op;
  1333.    
  1334.     system("cls");
  1335.    
  1336.     Quadro(1, 1, 25, 80, 2, 0);
  1337.    
  1338.     gotoxy(27,2);
  1339.    
  1340.     textcolor(15);
  1341.    
  1342.     printf("Alteracao de palestras");
  1343.    
  1344.     if(TLP == 0)
  1345.     {
  1346.         gotoxy(25,3);
  1347.         textcolor(4);
  1348.         printf("Nenhum palestra cadastrada");
  1349.         textcolor(15);
  1350.     }
  1351.     else
  1352.     {
  1353.         gotoxy(3,3);
  1354.         printf("Digite o codigo da palestra (0 para sair):");
  1355.         scanf("%d", &CodAux);
  1356.        
  1357.         while(CodAux > 0)
  1358.         {
  1359.             Pos = BuscaPalestra(Plst, TLP, CodAux);
  1360.            
  1361.             if(Pos == -1)
  1362.                 printf("Nenhuma palestra com esse codigo\n");
  1363.             else
  1364.             {
  1365.                 Op = MenuAlteraPalestra();
  1366.                
  1367.                 while(Op != 27)
  1368.                 {
  1369.                     gotoxy(3, 10);
  1370.                     switch(Op)
  1371.                     {
  1372.                         case 'A':
  1373.                            
  1374.                             printf("Nome atual: %s", Plst[Pos].Pal_Nome);
  1375.                            
  1376.                             gotoxy(3, 11);
  1377.                             printf("Digite o novo nome:");
  1378.                             fflush(stdin);
  1379.                             gets(Plst[Pos].Pal_Nome);
  1380.                            
  1381.                             while(strcmp(Plst[Pos].Pal_Nome, "\0") == 0)
  1382.                             {
  1383.                                 gotoxy(3, 12);
  1384.                                 textcolor(4);
  1385.                                 printf("Nome invalido. Digite um nome valido:");
  1386.                                 fflush(stdin);
  1387.                                 textcolor(15);
  1388.                                 gets(Plst[Pos].Pal_Nome);
  1389.                             }
  1390.                            
  1391.                             gotoxy(3, 13);
  1392.                            
  1393.                             printf("Nome alterado");
  1394.                         break;
  1395.                         case 'B':
  1396.                             printf("Horario atual: %s", Plst[Pos].Pal_Horario);
  1397.                            
  1398.                             gotoxy(3, 11);
  1399.                             printf("Digite o novo horario:");
  1400.                             fflush(stdin);
  1401.                             gets(Plst[Pos].Pal_Horario);
  1402.                            
  1403.                             while(strcmp(Plst[Pos].Pal_Horario, "\0") == 0)
  1404.                             {
  1405.                                 gotoxy(3, 12);
  1406.                                 textcolor(4);
  1407.                                 printf("Horario invalido. Digite um horario valido:");
  1408.                                 fflush(stdin);
  1409.                                 textcolor(15);
  1410.                                 gets(Plst[Pos].Pal_Horario);
  1411.                             }
  1412.                            
  1413.                             gotoxy(3, 13);
  1414.                            
  1415.                             printf("Horario alterado");
  1416.                         break;
  1417.                         case 'C':
  1418.                             printf("Vagas atuais: %d", Plst[Pos].Pal_TotVagas);
  1419.                            
  1420.                             gotoxy(3, 11);
  1421.                             printf("Digite o novo numero de vagas:");
  1422.                             scanf("%d", &Plst[Pos].Pal_TotVagas);
  1423.                            
  1424.                             while(Plst[Pos].Pal_TotVagas < 1)
  1425.                             {
  1426.                                 gotoxy(3, 12);
  1427.                                 textcolor(4);
  1428.                                 printf("Numero de vagas invalido. Digite um numero de vagas valido:");
  1429.                                 textcolor(15);
  1430.                                 scanf("%d", &Plst[Pos].Pal_TotVagas);
  1431.                             }
  1432.                            
  1433.                             gotoxy(3, 13);
  1434.                            
  1435.                             printf("Numero de vagas alterado");
  1436.                         break;
  1437.                         default:
  1438.                             textcolor(4);
  1439.                             printf("Opcao invalida");
  1440.                         break;
  1441.                     }
  1442.                    
  1443.                     getch();
  1444.                    
  1445.                     system("cls");
  1446.            
  1447.                     Quadro(1, 1, 25, 80, 2, 0);
  1448.                    
  1449.                     gotoxy(27,2);
  1450.                    
  1451.                     textcolor(15);
  1452.                    
  1453.                     printf("Alteracao de palestras");
  1454.                    
  1455.                     Op = MenuAlteraPalestra();
  1456.                 }
  1457.             }
  1458.            
  1459.             getch();
  1460.            
  1461.             system("cls");
  1462.    
  1463.             Quadro(1, 1, 25, 80, 2, 0);
  1464.            
  1465.             gotoxy(27,2);
  1466.            
  1467.             textcolor(15);
  1468.            
  1469.             printf("Alteracao de palestras");
  1470.            
  1471.             gotoxy(3,3);
  1472.             printf("Digite o codigo da palestra (0 para sair):");
  1473.             scanf("%d", &CodAux);
  1474.         }
  1475.     }
  1476.    
  1477.     getch();
  1478. }
  1479.  
  1480. char MenuRelatorioPalestras(void)
  1481. {
  1482.  
  1483.     gotoxy(3, 4);
  1484.     printf("[A] - Busca a partir do inicio");
  1485.     gotoxy(3, 5);
  1486.     printf("[B] - Busca em qualquer parte do titulo");
  1487.     gotoxy(3, 6);
  1488.     printf("[ESC] - Sair");
  1489.     gotoxy(15, 6);
  1490.     return toupper(getch());   
  1491. }
  1492.  
  1493. void RelatorioPalestras(TpPalestra Plst[TFP], int TLP)
  1494. {
  1495.     int i, linha = 4;
  1496.     char Op, NomeAux[40];
  1497.    
  1498.     system("cls");
  1499.    
  1500.     Quadro(1, 1, 25, 80, 2, 0);
  1501.    
  1502.     textcolor(10);
  1503.        
  1504.     gotoxy(30, 2);
  1505.    
  1506.     printf("Busca de Palestras por titulos");
  1507.    
  1508.     gotoxy(3, 3);
  1509.    
  1510.     textcolor(15);
  1511.    
  1512.     if(TLP == 0)
  1513.     {
  1514.         gotoxy(20,4);
  1515.         textcolor(4);
  1516.         printf("Nenhuma palestra cadastrada");
  1517.     }
  1518.     else
  1519.     {
  1520.         Op = MenuRelatorioPalestras();
  1521.        
  1522.         while(Op != 27)
  1523.         {
  1524.             gotoxy(3, 8);
  1525.             switch(Op)
  1526.             {  
  1527.                 case 'A':
  1528.                     printf("Digite o nome:");
  1529.                     fflush(stdin);
  1530.                     gets(NomeAux);
  1531.                    
  1532.                     system("cls");
  1533.                    
  1534.                     CabecalhoPalestras();
  1535.                    
  1536.                     for(i = 0; i < TLP; i++)
  1537.                         if(ProcuraInicio(Plst[i].Pal_Nome, NomeAux, strlen(NomeAux)) == 1)
  1538.                                 ImprimePalestra(Plst[i], linha);
  1539.                            
  1540.                            
  1541.                     linha = 4; 
  1542.                 break;
  1543.                 case 'B':
  1544.                     printf("Digite o nome:");
  1545.                     fflush(stdin);
  1546.                     gets(NomeAux);
  1547.                    
  1548.                     system("cls");
  1549.                    
  1550.                     CabecalhoPalestras();
  1551.                    
  1552.                     for(i = 0; i < TLP; i++)
  1553.                         if(ProcuraMeio(Plst[i].Pal_Nome, NomeAux) == 1)
  1554.                         {
  1555.                             ImprimePalestra(Plst[i], linha);
  1556.                             linha += 3;
  1557.                         }
  1558.                    
  1559.                     gotoxy(30, linha);
  1560.                    
  1561.                     textcolor(10);
  1562.                    
  1563.                     printf("Busca concluida");
  1564.                    
  1565.                     textcolor(15);
  1566.                    
  1567.                     linha = 4;
  1568.                 break;
  1569.                 default:
  1570.                     gotoxy(3, 8);
  1571.                     textcolor(4);
  1572.                     printf("Opcao invalida");
  1573.                 break;
  1574.             }
  1575.            
  1576.             getch();
  1577.            
  1578.             system("cls");
  1579.            
  1580.             Quadro(1, 1, 25, 80, 2, 0);
  1581.    
  1582.             textcolor(10);
  1583.                
  1584.             gotoxy(30, 2);
  1585.            
  1586.             printf("Busca de Palestras por titulos");
  1587.            
  1588.             gotoxy(3, 3);
  1589.            
  1590.             textcolor(15);
  1591.            
  1592.             Op = MenuRelatorioPalestras(); 
  1593.         }
  1594.     }
  1595.    
  1596.     textbackground(0);
  1597.    
  1598.     getch();
  1599. }
  1600.  
  1601. void InsercaoDireta(TpPalestra Plst[TFP], int &TLP, TpInscrito Insc[TFI], int &TLI,
  1602.     TpEstatistica Est[TFP])
  1603. {
  1604.     int i;
  1605.        
  1606.     TpPalestra InsercPalestra[5] = {{1, 2, "Big Data em Universidades", "21:00"},
  1607.                                     {2, 3, "Skills para ser cientista de dados", "18:30"},
  1608.                                     {3, 4, "Marcos tecnicos do Hadoop 3", "09:00"},
  1609.                                     {4, 5, "Impactos da IA nos empregos", "19:00"},
  1610.                                     {5, 10, "Usando Big Data em corporacoes", "20:30"}};
  1611.                                    
  1612.     TpInscrito InsercInscrito[5] = {{1, 1, 2, "Joao Victor Sierra", 'M', "Regente Feijo"},
  1613.                                     {2, 1, 2, "Lucas Gomes", 'M', "Pirapo"},
  1614.                                     {3, 3, 5, "Luana Campos", 'F', "Presidente Venceslau"},
  1615.                                     {4, 5, 4, "Sofia Vieira", 'F', "Sao Paulo"},
  1616.                                     {5, 1, 5, "Manoel Silva", 'M', "Uberaba"}};
  1617.    
  1618.     system("cls");
  1619.    
  1620.     if(TLP > 0 || TLI > 0)
  1621.     {
  1622.         textcolor(4);
  1623.         textbackground(8);
  1624.         printf("Ja existem dados cadastrados\n");
  1625.     }
  1626.     else
  1627.     {
  1628.         for(i = 0; i < 5; i++)
  1629.         {
  1630.             Plst[TLP].Pal_Codigo = InsercPalestra[i].Pal_Codigo;
  1631.             Plst[TLP].Pal_TotVagas = InsercPalestra[i].Pal_TotVagas;
  1632.             strcpy(Plst[TLP].Pal_Nome, InsercPalestra[i].Pal_Nome);
  1633.             strcpy(Plst[TLP].Pal_Horario, InsercPalestra[i].Pal_Horario);
  1634.            
  1635.             Est[TLP].Eve_Palestra = InsercPalestra[i].Pal_Codigo;
  1636.             Est[TLP].Eve_TotalInscritos = 0;
  1637.             Est[TLP].Eve_TotInscrFem = 0;
  1638.             Est[TLP].Eve_TotInscrMasc = 0;
  1639.            
  1640.             TLP++;
  1641.         }
  1642.        
  1643.         for(i = 0; i < 5; i++)
  1644.         {
  1645.             Insc[TLI].Ins_Numero = InsercInscrito[i].Ins_Numero;
  1646.             Insc[TLI].Cod_Palestra1 = InsercInscrito[i].Cod_Palestra1;
  1647.             Insc[TLI].Cod_Palestra2 = InsercInscrito[i].Cod_Palestra2;
  1648.             strcpy(Insc[TLI].Ins_Nome, InsercInscrito[i].Ins_Nome);
  1649.             strcpy(Insc[TLI].Ins_Cidade, InsercInscrito[i].Ins_Cidade);
  1650.             Insc[TLI].Ins_Sexo = InsercInscrito[i].Ins_Sexo;
  1651.            
  1652.             AtualizaEstatistica(Est[BuscaPalestra(Plst, TLP, InsercInscrito[i].Cod_Palestra1)],
  1653.                                 Est[BuscaPalestra(Plst, TLP, InsercInscrito[i].Cod_Palestra2)],
  1654.                                 InsercInscrito[i].Ins_Sexo, 1);
  1655.            
  1656.             TLI++;
  1657.         }
  1658.    
  1659.         CalculaEstatistica(Est, Plst, TLP, 0, 5);
  1660.         OrdenaEstatistica(Est, TLP);
  1661.         OrdenaInscrito(Insc, TLI);
  1662.         OrdenaPalestra(Plst, TLP);
  1663.        
  1664.         textbackground(4);
  1665.         textcolor(14);
  1666.         printf("Dados cadastrados\n");
  1667.     }
  1668.    
  1669.     textbackground(0);
  1670.    
  1671.     getch();
  1672. }
  1673.  
  1674. void CabecalhoEstatistica(void)
  1675. {
  1676.     QuadroSimples(1, 1, 4, 41, 15, 0);
  1677.     QuadroSimples(1, 42, 4, 50, 15, 0);
  1678.     QuadroSimples(1, 51, 4, 58, 15, 0);
  1679.     QuadroSimples(1, 59, 4, 65, 15, 0);
  1680.     QuadroSimples(1, 66, 4, 72, 15, 0);
  1681.     QuadroSimples(1, 73, 4, 80, 15, 0);
  1682.    
  1683.    
  1684.     textcolor(15);
  1685.    
  1686.     gotoxy(2,2);
  1687.     printf("Palestra");
  1688.     gotoxy(43,2);
  1689.     printf("Vagas");
  1690.     gotoxy(52,2);
  1691.     printf("Inscr");
  1692.     gotoxy(60,2);
  1693.     printf("Insc");
  1694.     gotoxy(60,3);
  1695.     printf("/vaga");
  1696.     gotoxy(67,2);
  1697.     printf("Homem");
  1698.     gotoxy(74,2);
  1699.     printf("Mulher");
  1700. }
  1701.  
  1702. void ImprimeEstatistica(TpEstatistica Est, TpPalestra Plst[TFP], int TLP, int linha)
  1703. {
  1704.     int Pos = BuscaPalestra(Plst, TLP, Est.Eve_Palestra);
  1705.    
  1706.     QuadroSimples(linha, 1, linha+3, 41, 15, 0);
  1707.     QuadroSimples(linha, 42, linha+3, 50, 15, 0);
  1708.     QuadroSimples(linha, 51, linha+3, 58, 15, 0);
  1709.     QuadroSimples(linha, 59, linha+3, 65, 15, 0);
  1710.     QuadroSimples(linha, 66, linha+3, 72, 15, 0);
  1711.     QuadroSimples(linha, 73, linha+3, 80, 15, 0);
  1712.            
  1713.     textcolor(WHITE);  
  1714.            
  1715.     gotoxy(2, linha+1);
  1716.     printf("%s", Plst[Pos].Pal_Nome);
  1717.     gotoxy(43, linha+1);
  1718.     printf("%d", Plst[Pos].Pal_TotVagas);  
  1719.     gotoxy(52, linha+1);
  1720.     printf("%d", Est.Eve_TotalInscritos);      
  1721.     gotoxy(60, linha+1);
  1722.     printf("%.2f", Est.Eve_InscrVagas);
  1723.     gotoxy(67, linha+1);
  1724.     printf("%d", Est.Eve_TotInscrMasc);
  1725.     gotoxy(74, linha+1);
  1726.     printf("%d", Est.Eve_TotInscrFem);
  1727. }
  1728.  
  1729. void ListaEstatistica(TpEstatistica Est[TFP], TpPalestra Plst[TFP], int TLP)
  1730. {
  1731.     int i, Pos, linha = 5;
  1732.    
  1733.     system("cls");
  1734.    
  1735.     if(TLP == 0)
  1736.     {
  1737.         gotoxy(30, 2);
  1738.         textcolor(4);
  1739.         printf("Nenhum palestra cadastrada");
  1740.     }
  1741.     else
  1742.     {
  1743.        
  1744.         CabecalhoEstatistica();
  1745.        
  1746.         for(i = 0; i < TLP; i++)
  1747.         {
  1748.             ImprimeEstatistica(Est[i], Plst, TLP, linha);
  1749.             linha += 4;
  1750.         }
  1751.    
  1752.         gotoxy(1, 1);
  1753.     }
  1754.    
  1755.     getch();
  1756. }
  1757.  
  1758. void ListaParecido(TpPalestra Plst[TFP], int TLP)
  1759. {
  1760.     int i, linha = 2;
  1761.     char Aux[40];
  1762.    
  1763.     system("cls");
  1764.    
  1765.     printf("**Busca por titulo similar**\n\n");
  1766.    
  1767.     if(TLP == 0)
  1768.     {
  1769.         textbackground(7);
  1770.         textcolor(4);
  1771.         printf("Nenhuma palestra cadastrada\n");
  1772.         textbackground(0);
  1773.         textcolor(7);
  1774.     }
  1775.     else
  1776.     {
  1777.         printf("Digite o titulo:\n");
  1778.         fflush(stdin);
  1779.         gets(Aux);
  1780.        
  1781.         while(strcmp(Aux, "\0") != 0)
  1782.         {
  1783.             system("cls");
  1784.            
  1785.             textbackground(4);
  1786.             textcolor(14);
  1787.        
  1788.            
  1789.             CabecalhoPalestras();
  1790.            
  1791.             for(i = 0; i < TLP; i++)
  1792.                 if(ProcuraMeio(Plst[i].Pal_Nome, Aux) == 1)
  1793.                     ImprimePalestra(Plst[i], linha++);
  1794.                    
  1795.             textbackground(0);
  1796.             textcolor(7);
  1797.            
  1798.             getch();
  1799.            
  1800.             system("cls");
  1801.            
  1802.             printf("Digite o titulo:\n");
  1803.             fflush(stdin);
  1804.             gets(Aux);
  1805.         }
  1806.     }
  1807.    
  1808.     getch();   
  1809. }
  1810.  
  1811. char MenuPrincipal(void)
  1812. {
  1813.     int Linha = 5;
  1814.     system("cls");
  1815.    
  1816.     Quadro(2, 20, 22, 54, 14, 0);
  1817.    
  1818.     Quadro(4, 22, 20, 52, 14, 0);
  1819.    
  1820.     textbackground(4);
  1821.     textcolor(14);
  1822.    
  1823.     gotoxy(28, 3);
  1824.    
  1825.     printf("MENU - Big Data Week");
  1826.    
  1827.     gotoxy(24,Linha++);
  1828.     printf("[A] - Incluir inscritos  ");
  1829.     gotoxy(24,Linha++);
  1830.     printf("[B] - Consultar inscritos");
  1831.     gotoxy(24,Linha++);
  1832.     printf("[C] - Alterar inscritos  ");
  1833.     gotoxy(24,Linha++);
  1834.     printf("[D] - Excluir inscritos  ");
  1835.     gotoxy(24,Linha++);
  1836.     printf("[E] - Exibir inscritos   ");
  1837.     gotoxy(24,Linha++);
  1838.     printf("[F] - Incluir palestras  ");
  1839.     gotoxy(24,Linha++);
  1840.     printf("[G] - Consultar palestras");
  1841.     gotoxy(24,Linha++);
  1842.     printf("[H] - Alterar palestras  ");
  1843.     gotoxy(24,Linha++);
  1844.     printf("[I] - Excluir palestras  ");
  1845.     gotoxy(24,Linha++);
  1846.     printf("[J] - Exibir palestras   ");
  1847.     gotoxy(24,Linha++);
  1848.     printf("[K] - Consultar por tema ");
  1849.     gotoxy(24,Linha++);
  1850.     printf("[L] - Relatorio por nome ");
  1851.     gotoxy(24,Linha++);
  1852.     printf("[M] - Exibir estatistica ");
  1853.     gotoxy(24,Linha++);
  1854.     printf("[N] - Insercao direta    ");
  1855.     gotoxy(24,Linha);
  1856.     printf("[ESC] - Sair             ");
  1857.    
  1858.     textbackground(0);
  1859.     textcolor(7);
  1860.    
  1861.     gotoxy(37, Linha);
  1862.    
  1863.     return toupper(getch());
  1864. }
  1865.  
  1866. void Executa(void)
  1867. {
  1868.     TpInscrito Insc[TFI];
  1869.     TpPalestra Plst[TFP];
  1870.     TpEstatistica Est[TFP];
  1871.     int TLI = 0, TLP = 0;
  1872.     char Op;
  1873.    
  1874.     Op = MenuPrincipal();
  1875.    
  1876.     while(Op != 27)
  1877.     {
  1878.         switch(Op)
  1879.         {
  1880.             case 'A':
  1881.                 IncluiInscrito(Insc, TLI, Plst, TLP, Est);
  1882.             break;
  1883.             case 'B':
  1884.                 ConsultaInscrito(Insc, TLI, Plst, TLP);
  1885.             break;
  1886.             case 'C':
  1887.                 AlteraInscrito(Insc, TLI, Plst, TLP, Est);
  1888.             break;
  1889.             case 'D':
  1890.                 RemoveInscrito(Insc, TLI, Plst, TLP, Est);
  1891.             break;
  1892.             case 'E':
  1893.                 ListaInscritos(Insc, TLI, Plst, TLP);
  1894.             break;
  1895.             case 'F':
  1896.                 IncluiPalestra(Plst, TLP, Est);
  1897.             break;
  1898.             case 'G':
  1899.                 ConsultaPalestras(Plst, TLP);
  1900.             break;
  1901.             case 'H':
  1902.                 AlteraPalestra(Plst, TLP);
  1903.             break;
  1904.             case 'I':
  1905.                 ExcluiPalestra(Plst, Insc, TLI, Est, TLP);
  1906.             break;
  1907.             case 'J':
  1908.                 ListaPalestras(Plst, TLP);
  1909.             break;
  1910.             case 'K':
  1911.                 ListaParecido(Plst, TLP);
  1912.             break;
  1913.             case 'L':
  1914.                 RelatorioPalestras(Plst, TLP);
  1915.             break;
  1916.             case 'M':
  1917.                 ListaEstatistica(Est, Plst, TLP);
  1918.             break;
  1919.             case 'N':
  1920.                 InsercaoDireta(Plst, TLP, Insc, TLI, Est);
  1921.             break;
  1922.             default:
  1923.                 gotoxy(28, 21);
  1924.                 textcolor(4);
  1925.                 textbackground(WHITE);
  1926.                 printf(" Opcao invalida ");
  1927.                 textcolor(7);
  1928.                 textbackground(0);
  1929.                 getch();
  1930.             break;
  1931.         }  
  1932.            
  1933.         Op = MenuPrincipal();
  1934.     }
  1935. }
  1936.  
  1937. int main(void)
  1938. {
  1939.     Executa();
  1940.    
  1941.     return 1;
  1942. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement