/*
(A)
The rainfall figures in mm are available for each day of the past four weeks.
Write a function generateReport() that displays the total rainfall for each
week and the most wettest day. The function takes as parameter a two-dimensional
array named, figures of size 4 x 7, that contains rainfall figures in which each
row represent a week and each column represent a day.
For example, if the array contains the following rainfall data:
Days
0 1 2 3 4 5 6
Week 0 3 0 0 7 8 21 0
Week 1 0 1 1 0 0 0 4
Week 2 9 6 7 0 0 0 0
Week 3 0 0 0 0 0 0 1
Then the output of the function should be displayed as follows:
Week Rainfall data Total
1 3 0 0 7 8 21 0 39
2 0 1 1 0 0 0 4 6
3 9 6 7 0 0 0 0 22
4 0 0 0 0 0 0 1 1
The wettest day was day 6 in week 1.
(B)
Write A program that prompt the user for input into 2D array and use the above
function for output.
*/
#include<iostream>
using namespace std;
void generatereport (int x[][7],int row)
{
int sum,wet=0,wek,maxd;
cout<<"Week Rainfall Total"<<endl;
for (int i=0;i<row;i++)
{
sum=0;
cout<<i+1<<"\t";
for (int j=0;j<7;j++)
{
cout<<x[i][j]<<" ";
sum+=x[i][j];
if (x[i][j]>wet)
{
wet=x[i][j];
wek=i;
maxd=j;
}
}
cout<<" \b\t"<<sum<<endl;
}
cout<<endl<<"The wettest day was day "<<maxd+1<<" in week "<<wek+1<<endl;
}
int main()
{
int x[4][7]={{3,0,0,7,8,21,0},{0,1,1,0,0,0,4},{9,6,7,0,0,0,0},{0,0,0,0,0,0,1}};
generatereport(x,4);
system ("pause");
return 0;
}