There are errors in your for loops. i+1 does not increment i.
If i is an int, to increment i write either ++i or i = i + 1 ;
If i is an enum, say location, there is no ++ or + operator. You need to write i = location( i + 1 ) ;