Sudoku in C++. The program works but how do I check the minisquares? Please gimme a function. :( Pretty please?

#include <iostream>
#include <iomanip>

using namespace std;

const int rowSize=9;
const int columnSize=9;
const int arraySize=9;
int a[arraySize];
int print_values[rowSize][columnSize]={9,4,2,5,1,8,3,7,6,
7,1,6,4,2,3,5,8,9,
3,8,5,7,6,9,4,2,1,
1,6,3,8,4,2,7,9,5,
4,2,7,1,9,5,6,3,8,
8,5,9,6,3,7,2,1,4,
6,3,8,9,7,4,1,5,2,
5,7,4,2,8,1,9,6,3,
2,9,1,3,5,6,8,4,7};

bool check(int a[], int arraySize){
int i=0;
for(int j=0; j<arraySize-1; j++){
if(a[j]==a[j+1])
i++;
}
if(i==0)
return true;
else
return false;
}

void swap(int &a, int &b){
int temp;
temp=a;
a=b;
b=temp;
}

void bubbleSort(int a[], int arraySize){
for(int i=0; i<arraySize-1; i++){
for(int j=0; j<arraySize-1; j++){
if (a[j]>a[j+1])
swap(a[j], a[j+1]);
}
}

}

//i for rows; j for columns
int check_row () {
int h=0;
for (int i = 0; i < 9; i++) {
for (int j=0; j<9; j++){
a[j]=print_values[i][j];
}
bubbleSort(a, arraySize);
if(check(a, arraySize))
h++;
}
return h;
}

/*int check_row (int rowSize){
for (int j=0;j<9;j++)
{
int total=0;
for (int i=0;i<9;i++)
{
total+=rowSize[j][i];
}
if(total!=45)
{
return false;
}
}
return true;
}
*/
int check_column(){
int h=9;
for(int j=0; j<9; j++){
for(int i=0; i<9; i++){
a[i]=print_values[i][j];
}

bubbleSort(a, arraySize);
if(check(a, arraySize))
h++;
}
return h;
}

int main(){

/*int n;

for(n=0; n<rowSize; n++){
cout << "Input value for sudoku:" << endl;
cin >> n;
}*/

if(check_row()!=9)
cout<<"Not a valid sudoku solution!"<<endl;
else{
if(check_column()==18)
cout<<"Valid sudoku solution!"<<endl;
}

return 0;
}

Sudoku in C++. The program works but how do I check the minisquares? Please gimme a function. :( Pretty please?

"Please gimme a function?" I don't think so. We are not a coding service to help write your code for you.

Figure out what the indecies are for a minisquare. Look at the pattern in those numbers. Then write your code based on this new knowledge.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.