Advertisement
hmcristovao

Lista 05 - exercício 01 - com #define

May 17th, 2012
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #define ANDARES 8
  3. #define APTOS 4
  4. int main() {
  5.    float consumo[ANDARES][APTOS];
  6.    int l,c;
  7.    for(l=0; l<ANDARES; l++) {
  8.       for(c=0; c<APTOS; c++) {
  9.          printf("Entre consumo do andar %d e apto %d:", l+1, c+1);
  10.          scanf("%f", &consumo[l][c]);
  11.       }
  12.    }
  13.    float soma = 0;
  14.    for(l=0; l<ANDARES; l++) {
  15.       soma = soma + consumo[l][1];
  16.    }
  17.    printf("Consumo total dos aptos da coluna 2: %f", soma);
  18.  
  19.    float soma2 = 0;
  20.    for(c=0; c<APTOS; c++) {
  21.       soma2 += consumo[4][c];
  22.    }
  23.    printf("Consumo total dos aptos do andar 5: %f", soma2);
  24.  
  25.    return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement