Join 132,161 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,745 people online right now. Registration is fast and FREE... Join Now!
Hi, I'm very new to C++ and our professor has given us sort of difficult assignment. We basically have to read in a sudoku puzzle and output the answer. I keep getting the error:
394 cannot convert `SetOfSmallInts**' to `SetOfSmallInts (*)[9]' for argument `1' to `void tacticOneSec(SetOfSmallInts (*)[9])'
I can't for the life of me figure out what that means/what to do. There error happens in bool tacticOne(Puzzle P)
/**************************************************************** * copyPuzzle * **************************************************************** * Copy puzzle p into pp. For example, if p is a puzzle, then * * Puzzle q; * * copyPuzzle(q, p); * * stores a copy of puzzle p into q. * ****************************************************************/
/**************************************************************** * getRow * **************************************************************** * Store the i-th row of puzzle p into puzzle section R. * * The rows are numbered from 0 to 8. * * * * After doing this, the k-th set in row i is *(R[k]). * * Do not omit *(...). The cells in the row are numbered * * 0,1,...,8. * ****************************************************************/
/**************************************************************** * getColumn * **************************************************************** * Store the j-th column of puzzle p into puzzle section R. * * The columns are numbered from 0 to 8. * * * * After doing this, the k-th set in column j is * * *(R[i]). Do not omit *(...). The cells in the * * column are numbered 0,1,...,8. * ****************************************************************/
void getColumn(PuzzleSection R, Puzzle p, int j) { int i; for(i = 0; i < 9; i++) { R[i] = &(p[i][j]); } }
/**************************************************************** * getSquare * **************************************************************** * Store the k-th square of puzzle p into puzzle section R. * * The squares are numbered as follows. * * 0 1 2 * * 3 4 5 * * 6 7 8 * * For example, square 4 is the middle square in the puzzle. * * * * After doing getSquare, the i-th set in the square is *(R[i]).* * Do not omit *(...). The cells in the square are numbered * * 0,1,...,8, in the same pattern shown above for the squares * * themselves. For example *(R[3]) is the first position in * * the second row of the square. * ****************************************************************/
void getSquare(PuzzleSection R, Puzzle p, int k) { int i; for(i = 0; i < 9; i++) { R[i] = &(p[k - k%3 + i/3][3*(k%3) + i%3]); } }
/**************************************************************** * readPuzzle * **************************************************************** * readPuzzle reads a puzzle in from standard input. * * Then it stores the puzzle into p * ****************************************************************/ void readPuzzle(Puzzle p) { char temp = '0'; ifstream inputFile; int rowCount = 0; int colCount = 0;
/**************************************************************** * printPuzzle * **************************************************************** * printPuzzle prints Puzzle p out in standard output. If the * * set is a singleton set it will write a number in that set. * * If it is not singleton, it will write '-'. If it is empty, * * it will write 0. * ****************************************************************/ void printPuzzle(Puzzle p) { int k; for(int i=0; i < 9; i++) { for(int j=0; j < 9; j++) { k= onlyMember(p[i][j]); if (j == 3 || j == 6) cout << " "; if (k == 0) cout << "-"; else cout << k; } if (i==2 || i == 5) cout << "\n"; cout <<"\n"; } } /**************************************************************** * showPuzzle * **************************************************************** * showPuzzle prints Puzzle p out in a suitable debugging form. * * It will print all members of each set. If the set has a * * singleton set or multiple numbers it will print that. * * If the set is empty it will just write zero. * * * ****************************************************************/
void showPuzzle(Puzzle p) { SetOfSmallInts s; int smallInt = 0;
/**************************************************************** * debugPuzzle * **************************************************************** * showPuzzle prints Puzzle p out in a suitable debugging form. * * It will print all members of each set. If the set has a * * singleton set or multiple numbers it will print that. * * If the set is empty it will just write zero. * * * ****************************************************************/
/**************************************************************** * Tactic 1 Sec * **************************************************************** * showPuzzle prints Puzzle p out in a suitable debugging form. * * It will print all members of each set. If the set has a * * singleton set or multiple numbers it will print that. * * If the set is empty it will just write zero. * * * ****************************************************************/ void tacticOneSec(Puzzle p) { SetOfSmallInts tempSet[9]; PuzzleSection section;
/**************************************************************** * Tactic 1 * **************************************************************** * Tactic 1 will run through each row, column and square of * * Puzzle p. Tatic 1 will return true if there was a change to * * any of the rows, columns, or squares. If nothing was changed * * it will return false. * ****************************************************************/ bool tacticOne(Puzzle p) { bool result = false; PuzzleSection scanSec; for(int i = 0; i < 9; i++) { getRow(scanSec,p,i); if(tacticOneSec(scanSec)) result = true; } for(int i = 0; i < 9; i++) { getColumn(scanSec,p,i); if(tacticOneSec(scanSec)) result = true; } for(int i = 0; i < 9; i++) { getSquare(scanSec,p,i); if(tacticOneSec(scanSec)) result = true; } return result; } /**************************************************************** * allSingle * **************************************************************** * allSingle will run though puzzle p to make sure all sets * * are singleton sets. If they are allSingle will return true. * * If there is a nonsingleton set it will return false. * ****************************************************************/
bool allSingle(Puzzle p) { bool final = false; SetOfSmallInts tatOne; for( int i = 0; i < 9; i++) { for( int j = 0; i < 9; j++) { tatOne=p[i][j]; if(isSingleton(tatOne)) final = true; else return false; } return final; } } /**************************************************************** * solver * **************************************************************** * Solver will find the solution to the puzzle. Solver will run* * tactic 1 then do a debug print. If the solver will run * * through tactic 1 until all sets are singleton sets. * ****************************************************************/
Sure sorry about that theres two intset files ones a .h and the other is .cpp
here is also the puzzle I've been using
CODE
1-- 489 --6 73- --- -4- --- --1 295
--7 12- 6-- 5-- 7-3 --8 --6 -95 7--
914 6-- --- -2- --- -37 8-- 512 --4
CODE
#include "intset.h"
/**************************************************************** * Note: This file uses capabilities of treating integers * * as sequences of bits. For example, integer 12 on a * * 32 bit machine is 00000000000000000000000000001100. * * The rightmost bit is the 1's column, the next bit the * * 2's column, etc. The columns are numbered, from right to * * left, starting at 0. A set is represented by putting a 1 in * * column k if k is in the set, and a 0 if k is not in the set. * * For example, set {2,5} is represented as integer * * 00000000000000000000000000100100. * * * * Operations are as follows. * * * * x & y The bitwise "and" of x and y. (The result has * * a 1 in each column whether both x and y have a * * 1.) This has the effect of intersecting sets. * * * * x | y The bitwise "or" of x and y. (Ther result has * * a 1 in each column whether either x or y or * * both have a 1.) This has the effect of taking * * the union of sets. * * * * ~x The bitwise complement of x. The result has a * * 1 in each column where x has a 0, and a 0 in * * each column where x has a 1. * * * * x >> k The result of shifting x to the right k bits. * * (Normally, the leftmost bit is duplicated k * * times.) * * * * x << k The result of shifting x to the left k bits. * * Normally, the rightmost k bits become 0. * ****************************************************************/
const SetOfSmallInts emptySet;
/*********************************************************** * makeSet * *********************************************************** * Return the set represented by integers i. * ***********************************************************/
/**************************************************************** * SetOfSmallInts * **************************************************************** * A value of type SetOfSmallInts is a set of the integers from * * 1 to 9. When you create a variable of type SetofSmallInts, * * it initially holds an empty set. * ****************************************************************/
struct SetOfSmallInts { int ival;
SetOfSmallInts() { ival = 0; } };
/**************************************************************** * emptySet * **************************************************************** * emptySet is an empty set. * ****************************************************************/
extern const SetOfSmallInts emptySet;
/**************************************************************** * singletonSet * **************************************************************** * singletonSet(x) is the set {x}. * ****************************************************************/
SetOfSmallInts singletonSet(int x);
/**************************************************************** * rangeSet * **************************************************************** * rangeSet(x,y) is the set {x,x+1,...,y}. For example, * * rangeSet(2,5) is the set {2,3,4,5}. * ****************************************************************/
SetOfSmallInts rangeSet(int x, int y);
/**************************************************************** * size * **************************************************************** * size(s) returns the number of members of set s. * ****************************************************************/
int size(SetOfSmallInts s);
/**************************************************************** * isEmpty * **************************************************************** * isEmpty(s) is true if s is an empty set. * ****************************************************************/
bool isEmpty(SetOfSmallInts s);
/**************************************************************** * isSingleton * **************************************************************** * isSingletonSet(s) is true if s is a singleton set. That is, * * it is true if s has exactly one member. * ****************************************************************/
bool isSingleton(SetOfSmallInts s);
/**************************************************************** * member * **************************************************************** * member(x,s) is true if x is a member of s. * ****************************************************************/
bool member(int x, SetOfSmallInts s);
/**************************************************************** * setDifference * **************************************************************** * setDifference(s,t) is the set of all numbers that are in s, * * but not in t. * ****************************************************************/
/**************************************************************** * setUnion * **************************************************************** * setUnion(s,t) is the set of all numbers that are in either s * * or t (or both). * ****************************************************************/
/**************************************************************** * setIntersection * **************************************************************** * setIntersection(s,t) is the set of all numbers that are in * * both s and t. * ****************************************************************/
/**************************************************************** * insert * **************************************************************** * insert(x,s) returns the set that you get by adding x to * * set s. So it is equivalent to setUnion(s, singletonSet(x)). * ****************************************************************/
SetOfSmallInts insert(int x, SetOfSmallInts s);
/**************************************************************** * remove * **************************************************************** * remove(x,s) returns the set that you get by removing x from * * set s. So it is equivalent to * * setDifference(s, singletonSet(x)). * ****************************************************************/
SetOfSmallInts remove(int x, SetOfSmallInts s);
/**************************************************************** * smallest * **************************************************************** * smallest(s) returns the smallest member of s. If s is empty,* * then smallest(s) returns 0. * ****************************************************************/
int smallest(SetOfSmallInts s);
/**************************************************************** * onlyMember * **************************************************************** * If s is a singleton set, then onlyMember(s) returns the * * member of s. If s is not a singleton set, then * * onlyMember(s) returns 0. * ****************************************************************/