lab38.cpp:27: error: request for member `push_back' in `*(&itr)->__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator-> [with _Iterator = uint*, _Container = std::vector<uint, std::allocator<uint> >]()', which is of non-class type `unsigned int'
*** Error code 1
make: Fatal error: Command failed for target `lab38.o'
the program looks at the one's place of a vector and puts it into buckets,after that it puts them back into the vector ,then it looks at the 10s place ant puts those into a bucket and puts it back into the vector so on. the buckets are a vector of vector going from 0-9
it looks like so
v=53,72,42,11,31
pass 1 pass2
0| 0|
1| 11 31 1| 11
2| 42 72 2|
3|53 3| 31
4| 4| 42
> the program looks at the one's place of a vector and puts it into buckets
the program traverse the vector and puts each element in a bucket according to the last digit.
However I don't see anywhere in your code where you fill `mat', the bucket list.
1 2 3 4 5
for(size_t K=0; K<v.size(); ++K){
int number = v[K];
int digit = number % 10;
bucket[digit].push_back(number);
}
> after that it puts them back into the vector
¿put them back how? ¿in the order of traversal?
> then it looks at the 10s place ant puts those into a bucket and puts it back into the vector so on
the it looks the next digit and repeat the operation.
1 2 3 4 5 6 7 8 9
for(int i = 0, factor=1; i < numDigits ;++i, factor*=10){
std::vector< std::vector<uint> > bucket; //limit the scope, you may also declare it outside and do bucket.clear()
//puts each element of the vector in a bucket according to the digit.
//int digit = number/factor % 10;
v.clear(); //I suppose that you don't want duplicates
//puts the element of the bucket them back into the vector
}
> also i thought rowitr + j would increment through rowitr j times. how would i get it to do so?
you never catch the result value, I doubt that you want to modify `rowitr' as that would affect the outer loop.
So foo = rowitr+j; and then use `foo'
Now, `rowitr+j' means `j' rows after the one that `rowitr' points to.