#include #define ANNOS 3 #define MESES 12 int main() { float lluvia[ANNOS][MESES] = {{10.2, 8.1, 6.8, 4.2, 2.1, 1.8, 0.2, 0.3, 1.1, 2.3, 6.1, 7.4}, {9.2, 9.8, 4.4, 3.3, 2.2, 0.8, 0.4, 0.0, 0.6, 1.7, 4.3, 5.2}, {6.6, 5.5, 3.8, 2.8, 1.6, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2}}; int anno, mes; double subtotal, total; /* variables locales */ puts("Aņo Lluvia (cm) Media (cm)\n"); for (anno = 0, total = 0; anno < ANNOS; anno++, total += subtotal) { for (mes = 0, subtotal = 0; mes < MESES; mes++) subtotal += lluvia[anno][mes]; /* subtotal por aņo */ printf("%d %lf %lf\n", 1970 + anno, subtotal, subtotal/MESES); /* subtotal/MESES: media mensual por aņo */ } printf("\nEl promedio anual ha sido: %lf cm.\n\n", total/ANNOS); system("pause"); return 0; }