Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:33:24+00:00 2026-06-12T08:33:24+00:00

Alright so my problem is that I have no idea where to go in

  • 0

Alright so my problem is that I have no idea where to go in my situation with my Sudoku Program. As of right now I have multiple programs that work together to create my Sudoku program which is SUPPOSED to take input of 9 lines with 9 characters each whether it be just spaces or numbers.
example:

53  7    
6  195   
 98    6
8   6   3
4  8 3  1
7   2   6
 6    28
   419  5
    8   79

What the program would yield would be:

534678912
672195348
198342567
859761423
426853791
713924856
961537284
287419635
345286179

My current programs consist of the files stack.h, stack.cc, sudokuboard.h sudokuboard.cc, sudoku.cc, and Makefile, as well as test.txt(consists the example of input i had above)

the programs stack.h:

struct Node {
  StackElementType data;
  Node *next;
};
class Stack {
 public:

 Stack(); //constructor
 ~Stack(); //deconstructor
 Stack(const Stack & orig); // copy constructor
 void output(ostream & ostr) const; //output method
 bool empty() const; // if empty returns true
 void push(const StackElementType & item); // puts new item on top of stack
 void pop(); // removes top element of nonempty stack
 StackElementType top() const; // returns copy of top element of a stack

 private:
 Node*first;
 size_t _size;
}

Note that there may be misspellings in this due to having to being unable to copy my code directly so most of this is freshly typed out.

My stack.cc is

#include "stack.h"
#include <cstdlib>
#include <cassert>

void destroy(Node *p)
{
  // delete all nodes dominated by p.
  while (p != NULL) {
    Node *old = p;
    p = p->next;
    delete old;
  }
}

Node *copy(Node *p)
{
  // Make a deep copy of linked list dominated by p.
  Node *result = NULL;
  if (p != NULL) {
    result = new Node;
    Node *last = result;
    while (p != NULL) {
      // invariant: last points to a node ready to receive p's data.
      last->data = p->data;
      last->next = NULL;
      p = p->next;
      if (p != NULL) {
    // there's going to more to this copy.  Get it ready.
    last->next = new Node;
    last = last->next;
      }
    }
  }
  return result;
}

Stack::Stack()
{
  first = NULL;
}

Stack::~Stack()
{
  destroy(first);
}

Stack::Stack(const Stack & orig)
{
  first = copy(orig.first);
}

Stack & Stack::operator=(const Stack & rhs)
{
  if (this != &rhs) 
    first = copy(rhs.first);
  return *this;
}

void Stack::output(ostream & ostr) const
{
  ostr << "<";
  for(Node *p = first;p;p=p->next) {
    ostr << p->data;
    if (p->next)
      ostr << ", ";
  }
  ostr << ">";
}

void Stack::push(const ElementType & item)
{
  Node *born = new Node;
  born->data = item;
  born->next = first;
  first = born;
}

void Stack::pop()
{
  assert(!empty());
  Node *rest = first->next;
  delete first;
  first = rest;
}

ElementType Stack::top() const
{
  assert(!empty());
  return first->data;
}

bool Stack::empty() const
{
  return first==NULL;
}

So this is simply what I am using for my stack

My sudokuboard.h:

#include <iostream>

#define SDIM 9

class SudokuBoard {
 public:
  //------------------------------------------------------------------------
  SudokuBoard();
  // Construct a blank sudoku board
  //------------------------------------------------------------------------

  //------------------------------------------------------------------------
  void print(std::ostream & ostr) const;
  // display it.  duh.
  //------------------------------------------------------------------------

  //------------------------------------------------------------------------
  void place(size_t r, size_t c, char digit);
  // PRE: safe(r,c,digit)
  //------------------------------------------------------------------------

  //------------------------------------------------------------------------
  void remove(size_t r, size_t c, char digit); 
  // PRE: get(r,c) == digit
  //------------------------------------------------------------------------

  //------------------------------------------------------------------------
  char get(size_t r, size_t c) const;
  // Return the digit at (r,c) on the board.  or ' ' if blank.
  //------------------------------------------------------------------------

  //------------------------------------------------------------------------
  bool safe(size_t r, size_t c, char digit) const;
  // 
  //------------------------------------------------------------------------

  //------------------------------------------------------------------------
  bool done() const; 
  // Return true iff every cell has a number
  //------------------------------------------------------------------------
 private:
  std::string rows[SDIM];
};

While my sudokuboard.cc

#include <iostream>
#include <cassert>
#include "sudokuboard.h"

#define ASSERTBOUNDS assert(0 <= r and r < SDIM and 0 <= c and c < SDIM)

SudokuBoard::SudokuBoard()
{
  for (size_t i = 0;i<SDIM;i++) {
    rows[i] = "";
    for (size_t j=0;j<SDIM;j++)
      rows[i] += ' ';
  }
}

void SudokuBoard::place(size_t r, size_t c, char digit)
{
  ASSERTBOUNDS;
  assert(safe(r,c,digit));
}

void SudokuBoard::remove(size_t r, size_t c, char digit)
{
  ASSERTBOUNDS;
  assert(get(r,c)==digit);
  rows[r][c] = ' ';
}

char SudokuBoard::get(size_t r, size_t c) const
{
  ASSERTBOUNDS;
  return rows[r][c];
}


void SudokuBoard::print(std::ostream & ostr) const
{
  for (size_t i=0;i<SDIM;i++)
    ostr << rows[i] << std::endl;
}
bool SudokuBoard::safe(size_t r, size_t c, char digit) const
{
 for(size_t r=0; r<SDIM; r++)
    for(size_t c=0; c<SDIM; c++)
       if (get(r,c) == digit)
           return false;

 for(size_t c=0; c<SDIM; c++)
    for(size_t r=0; r<SDIM; r++)
       if (get(r,c) == digit)
           return false;
  return true;
}
bool SudokuBoard::done() const
{
  for (size_t r=0;r<SDIM;r++)
    for (size_t c=0;c<SDIM;c++)
      if (rows[r][c]==' ')
    return false;
  return true;
}

My sudoku.cc right now is pretty much blank because I have only a general idea on how to pursue my goal. The way I am going to fill in the empty spaces is that I am going to take to take a single area and put in the smallest possible number in its current row/column and if there is a higher number in its row/column is goes up +1. I then go down the column and so on.

My question is how do i integrate the following programs of sudokuboard.cc and stack.cc in my sudoku.cc. I know I have to get the input of test.txt some how and convert each of the lines to the empty board, but I don’t know how to phrase the cin input for that at all!

In other words I am looking for any help to get my sudok.cc started and how should I approach it?

sudoku.cc

#include <iostream>
#include <cassert>
#include "sudokuboard.h"
#include "stack.h"

int main()
{


}

I just want to say thank you who gave me these answers, now my lab is well on its way thanks to you guys! I cannot give any of you points b/c my rep is too low but otherwise i would!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:33:25+00:00Added an answer on June 12, 2026 at 8:33 am

    The method I would use to read the text file:

    //Code here
    std::ifstream infile("test.txt", std::ios::binary);
    if(infile.is_open())
    {
        char szFileData[32]; //I think we can assume that each line won't be above 32 bytes
        infile.getline(szFileData, 32);
        do
        {
           //Set the cells to the data you just pulled
           infile.getline(szFileData, 32);
        }while(infile.good());
    }
    else
    {
       std::cout<<"Unable to open file!"<<std::endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so heres my problem: I have an application I am working with that
Alright. The problem we're having is that we have NSStrings filled with dates in
Alright, this problem is a little complicated, so bear with me. I have a
Alright so I have no idea how to even begin doing this But basically
Alright, so I have a button that when clicked, will change the class of
Alright so I have a JFrame that I have a KeyListener added to, and
Alright, I have a script that takes a few arguments, runs data, and then
Alright so I'm trying to create a method called: setIncrement(). I have two classes
First, the formula I'm currently using: =countifs('page1'!AF:AF,$L6,'page1'!AA:AA,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AB:AB,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AC:AC,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AD:AD,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AE:AE,=&RIGHT(M$2,3))+countifs('page1'!AF:AF,$L6,'page1'!AF:AF,=&RIGHT(M$2,3)) Alright, now, what I'm attempting to match
Alright, I have the following: wchar_t **filePathList; This holds a list of files that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.