Sudoku Traverse

#include <bits/stdc++.h> using namespace std; int main () { int i, j, k, n, t; char m; cin >> t; while (t--) { std::vector < int >SubBlocks[26]; std::vector < int >Board[26]; std::vector < int >col[26]; n=4,f=0; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> m; if(m=='*'){ f++; m='0'; } Board[i].push_back (m - '0'); } } int subBlocksNumber = 0, len = sqrt (n); for (i = 0; i < n; i++) { int count = 0; for (j = 0; j < n; j++) { col[i].push_back (Board[j][i]); SubBlocks[subBlocksNumber].push_back (Board[i][j]); count++; if (count == len) { count = 0; subBlocksNumber++; } } if (SubBlocks[subBlocksNumber - 1].size () != n) { subBlocksNumber = subBlocksNumber - (len); } } /*for (i = 0; i < n; i++) { cout << "Sub Block No:" << i << endl; for (j = 0; j < SubBlocks[i].size (); j++) { if(j==len) cout<<endl; cout << SubBlocks[i][j] << " "; } cout << endl << endl; }*/ } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.