Advertisement
Hansrrr

C

Mar 27th, 2021
442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. int main()
  6. {
  7.     int i, employee, customers;
  8.    
  9.     scanf("%d", &employee);
  10.     scanf("%d", &customers);
  11.     int timeByEmployee[employee];
  12.     int itemsByCustomers[customers];
  13.  
  14.     //Preencher a Lista com os nomes
  15.     for(i = 0; i < employee; i++)
  16.         scanf("%d", &timeByEmployee[i]);
  17.  
  18.     for(i = 0; i < customers; i++)
  19.         scanf("%d", &itemsByCustomers[i]);
  20.    
  21.        
  22.     int tempoGasto[employee];
  23.     int t =0;
  24.     while(t < customers){
  25.         if(t < employee){
  26.             tempoGasto[t] = itemsByCustomers[t] * timeByEmployee[t];
  27.             t++;
  28.         }
  29.         else{
  30.             int index = tempoGasto[0];
  31.             int z = 0;
  32.             for(i = 0; i < employee; i++)
  33.                 if(index > tempoGasto[i])
  34.                 {
  35.                     index = tempoGasto[i];
  36.                     z = i;
  37.                 }
  38.             tempoGasto[z] += itemsByCustomers[t] * timeByEmployee[z];
  39.    
  40.             z = 0;
  41.             t++;
  42.         }
  43.     }
  44.     int index = tempoGasto[0];
  45.  
  46.     for(i=0; i < employee; i++){
  47.         printf("%d ",tempoGasto[i]);
  48.     }
  49.     for(i = 0; i < employee; i++)
  50.         if(index < tempoGasto[i])
  51.             index = tempoGasto[i];
  52.         printf("\n%d\n", index);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement