Advertisement
Jvsierra

quebra

Apr 16th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.  
  8.     int codSetor, mat, setores = 0, funcs = 0, funcsSetor, setorMaiorSalario = 0;
  9.     float sal, totSal = 0, totSalSetor = 0, maiorSalSetor, maiorSalario = 0;
  10.     char nome[20], nomeMaiorSalario[20];
  11.    
  12.     printf("Digite o codigo do setor:\n");
  13.     scanf("%d", &codSetor);
  14.    
  15.     while(codSetor > 0)
  16.     {
  17.         printf("Digite o numero da matricula:\n");
  18.         scanf("%d", &mat);
  19.        
  20.         funcsSetor = 0;
  21.         totSalSetor = 0;
  22.         maiorSalSetor = 0;
  23.        
  24.         setores++;
  25.        
  26.         while(mat > 0)
  27.         {
  28.             printf("Digite o salario do funcionario:\n");
  29.             scanf("%f", &sal);
  30.            
  31.             totSalSetor += sal;
  32.            
  33.             printf("Digite o nome do funcionario:\n");
  34.             fflush(stdin);
  35.             fgets(nome, 20, stdin);
  36.            
  37.             if(sal > maiorSalSetor)
  38.             {
  39.                 maiorSalSetor = sal;
  40.                 strcpy(nomeMaiorSalario, nome);
  41.             }
  42.            
  43.             funcsSetor++;
  44.            
  45.             printf("Digite o numero da matricula:\n");
  46.             scanf("%d", &mat);
  47.         }
  48.        
  49.         funcs += funcsSetor;
  50.        
  51.         if(totSalSetor > maiorSalario)
  52.         {
  53.             maiorSalario = totSalSetor;
  54.             setorMaiorSalario = codSetor;
  55.         }
  56.        
  57.         totSal += totSalSetor;
  58.        
  59.         printf("Trabalham %d funcionarios nesse setor\n", funcsSetor);
  60.         printf("A empresa paga um total de R$%.2f de salario nesse setor\n", totSalSetor);
  61.         printf("O funcionario que mais ganha nesse setor se chama %s\n", nomeMaiorSalario);
  62.        
  63.         printf("Digite o codigo do setor:\n");
  64.         scanf("%d", &codSetor);
  65.     }
  66.    
  67.     if(setores == 0)
  68.         printf("Nenhum setor registrado\n");
  69.     else
  70.     {
  71.         printf("%d setores na empresa\n", setores);
  72.         printf("%d funcionarios na empresa\n", funcs);
  73.         printf("R$%.2f pago de salario pela empresa\n", totSal);
  74.         printf("O setor de codigo %d gasta mais em salarios\n", setorMaiorSalario);
  75.     }
  76.    
  77.     getch();
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement