# Thread: Issue with vector of vectors

1. ## Issue with vector of vectors

Hey all. I just joined this community and would really appreciate some help. In class right now we are dealing with a vector of vectors, that holds a bunch of different precipitation vlaues in it for many different months. It runs parallel to a vector that holds the index for the year/month. My issue is with one part we are looking for the month with the least rainfall and a different function looking for the month with the most rainfall. I tried both of them two different ways and neither are returning properly with the test values we were given.
insert
Code:
```***********{LEAST GIVEN BELOW}*************************
int least (vector<vector<double>>& precipitation, vector<int>& dates){
double small, min;
int date = 0, permDate = 0;
small = accumulate(precipitation.begin(), precipitation.end(), 0.0);
cout << small;
min = small;
for(vector<int>::size_type i = 1; i < dates.size(); ++i){
date++;
small = accumulate(precipitation[i].begin(), precipitation[i].end(), 0.0);
if(small < min){
min = small;
permDate = date;
}
}
permDate = permDate - 1;
return dates[permDate];
}
*************{MOST GIVEN BELOW}*******************
int most (vector<vector<double>>& precipitation, vector<int>& dates){
int date = 0;
int permDate = 0;
double number;
double greatest = 0;
for(auto n : precipitation){
number = 0;
date++;
number = total(precipitation, (date-1));
if(number > greatest){
greatest = number;
cout << greatest << endl;
permDate = date;
}
}
permDate = permDate - 1;
return dates[permDate];
}

*****{MOST USES FUNCTION TOTAL, GIVEN BELOW}***********
double total(vector<vector<double>>& precipitation, int n){
double all = 0;
for(auto a : precipitation[n]){
all = all + a;
}
return all;
}``` 2. The issue is that neither of these methods set number back to 0, and it just keeps adding on top of the values from the previous months. Any help would be amazing, thank you guys. 3. spDataProcHWprecip.cpp:40:55: error: '>>' should be '> >' within a nested template argument list 4. Originally Posted by userxbw spDataProcHWprecip.cpp:40:55: error: '>>' should be '> >' within a nested template argument list
That isn't an issue anymore, not since C++11 at least.

@xtyler: Give an example of the input, and the output you expect. Chances are, you'll find the error yourself while preparing the demonstration. Without that it's fairly challenging to help. 5. Originally Posted by -Adrian That isn't an issue anymore, not since C++11 at least.

@xtyler: Give an example of the input, and the output you expect. Chances are, you'll find the error yourself while preparing the demonstration. Without that it's fairly challenging to help.
Code:
`std=c++11 ``
well I fixed it anyways, out 6. An example rainfall.txt would make it so much easier for us to get up and running and testing. Popular pages Recent additions #### Tags for this Thread

holds, homework help, precipitation, vector, vector of vectors 