nikolas_serafini

Lista 5 - Exercício 2

Jun 29th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.    
  6.     int i,j,floors,apartments;
  7.     float buildingEnergy[8][4],floorEnergy[8] = {0},secondColummnEnergy = 0;
  8.  
  9.     printf("Entre com a quantidade de andares :\n");
  10.     scanf("%d",&floors);
  11.     printf("Entre com a quantidade de apartamentos por andar:\n");
  12.     scanf("%d",&apartments);
  13.    
  14.     for (i = 0; i < floors; i++)
  15.     {
  16.         for (j = 0; j < apartments; j++)
  17.         {
  18.             printf("Entre com o consumo medio do apartamento %d do %d andar:\n",j+1,i+1);
  19.             scanf("%f",&buildingEnergy[i][j]);
  20.             floorEnergy[i] += buildingEnergy[i][j];
  21.             if (j == 1)
  22.                 secondColummnEnergy += buildingEnergy[i][j];
  23.         }
  24.     }
  25.  
  26.     printf("Consumo total dos apartamentos da segunda coluna : %.3f\n",secondColummnEnergy);
  27.     for (i = 0; i < 8; i++)
  28.     {
  29.         printf("Consumo total do andar %d = %.3f\n",i+1,floorEnergy[i]);
  30.     }
  31.        
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment