I am trying to rotate a vvc
vector of Vectors of chars.
I made a 2d vector matrix setup. right now the matrix takes input from a file, I use vector.push_back(c) to add the characters to the vvc; An example of the vvc array would be something like this
aaaaa
azzza
azaza
azzza
azaaa
azaaa
azaaa
aaaaa
I have the vvc setup, But I am trying to rotate it 90 degrees. I rotated it 90 degrees counter clockwise but I need to rotate it 90 degrees clockwise.
as of right now my code does this
90 counter clock
aaaaaaaa
azzzzzza
azazaaaa
azzzaaaa
aaaaaaaa
and it does it through this loop;
cout <<"\n90 counter clock"<<endl;
for (size_t colNo = 0; colNo < kvsize2; colNo++)
{
for (const auto &row : twovector)
{
char colVal = row.at(colNo);
cout << colVal;
}
cout << endl;
}
i am kind of new to C++ and I am just learning about vectors, and the Auto loop function.
trying to do a decriment loop almost works, but keeps throwing me into a segfault.
I have been stuck on this problem for the past 6 hours and I am starting to get really frustrated.
If anyone has any tips or suggestions on how to rotate a M*N 2d vector array
vector<vector<char>> twovector; // 2d array
that would be really really helpful.
thanks
Aucun commentaire:
Enregistrer un commentaire