Hello I need to create a table (using multidimensional array/vector) that contains datas in a spiral form. Here's my work so far: int current_char = 0, rows = 3, columns = 4; string input = "abcdefghijkl"; vector< vector<string> > str_table(rows, vector<string>(columns)); for(int i = 0; i < (int)input.length(); i++) { splitted_input.push_back(input.substr(i, 1)); } for(int x = 0; x < rows; x++) { for(int y = 0; y < columns; y++) { str_table[x][y] = splitted_input.at(current_char); current_char++; } } Code (markup): and it produces... (illustrated below) Now my problem is making it spiral.. any ideas? (sorry i made the illust. using mspaint )
Looks like a very simple programming problem to me. Unfortunately I don't know anything about the C languages. In FoxPro I would just fill in the array in a spiral fashion while incrementing your letters by one each time. I suspect that if I played around with it in FP, I could probably do it in less than 10 lines of code. Like fill the first row, then fill the last column, then fill the last row backwards, then fill the first row less one backwards, then fill the 2nd row less one, and so on until done.