Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX_ANDAR 8
- #define MAX_COL 4
- int main() {
- float predio[MAX_ANDAR][MAX_COL];
- int lin, col;
- for(lin=0; lin<MAX_ANDAR; lin++)
- for(col=0; col<MAX_COL; col++) {
- printf("Consumo do apto %d: ", (lin+1)*100 + col+1);
- scanf("%f", &predio[lin][col]);
- }
- float somaSegCol = 0;
- // conumo total da segunda coluna do prédio
- for(lin=0; lin<MAX_ANDAR; lin++)
- somaSegCol += predio[lin][1];
- printf("Conumo da segunda coluna: %f\n", somaSegCol);
- // calcula soma de cada andar
- float somaAndar;
- for(lin=0; lin<MAX_ANDAR; lin++)
- for(col=0; col<MAX_COL; col++) {
- somaAndar += predio[lin][col];
- printf("Consumo do andar %d: %f\n", lin+1, somaAndar);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement