Jvsierra

trab 2

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