hi, i am creating a program that reads input from a file into a sudoku square. and my program is supposed to check all rows, columns, grids for any repeat numbers, and if there are repeat numbers, the program is supposed to tell me which number is being repeated in a particular row/column/grid. below is the code i wrote, but there seemed to be some problems. can someone tell me what is wrong? thanks very much.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
char file[] = "sud1.txt";
int collect(int i, int di, int n, int mask)
{
cout << file << ":" << endl << endl;
ifstream in("C:\\Documents and Settings\\HP\\Desktop\\sud1.txt");
vector<int> S;
int buffer;
while(in>>buffer)
S.push_back(buffer);
if(S.size()==81)
cout << "input worked" << endl;
else
cout << "input error" << endl;
for(; n--;i+=di)
{
mask|=1<<S.at(i)-1;
return mask;
}
}
int main(int argc, char *argv[])
{
enum bitflag
{
bitflag1 = 0x001,
bitflag2 = 0x002,
bitflag3 = 0x004,
bitflag4 = 0x008,
bitflag5 = 0x010,
bitflag6 = 0x020,
bitflag7 = 0x040,
bitflag8 = 0x080,
bitflag9 = 0x100,
};
bitflag == (0x001||0x002||0x004||0x008||0x010||0x020||0x040||0x080||0x100);
int i;
for(int i=0;i<81;i+=9)
{
if (collect(i, 1, 9, 0) != bitflag)
cout<<i<<" appears twice in row "<<(i/9)+1<<endl;
}
int j;
for(int j=0;j<81;j+=9)
{
if (collect(j, 1, 9, 0) != bitflag)
cout<<j<<" appears twice in row "<<(j/9)+1<<endl;
}
int grid[9];
for(int grid=0;grid<9;grid++)
{
if (collect(grid, 1, 3, 0) != bitflag)
cout<<grid<<" appears twice in grid "<<(j/3)+1<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
the input test file is
8 3 2 5 9 1 6 7 4
4 9 6 3 8 7 2 5 1
5 7 1 2 6 4 9 8 3
1 8 5 7 4 6 3 9 2
2 6 7 9 5 3 4 1 8
9 4 3 8 1 2 7 6 5
7 1 4 6 3 8 5 2 9
3 2 9 1 7 5 8 4 6
6 5 8 4 2 9 1 3 7
the errors given are as follows:
for the line highlighted in green : expected primary expression before '==' token.
for those in red: expected primary expression before ')' token.
if you notice any other problems with my code, please tell me.
thank you very much for your time!