Click here to Skip to main content
15,915,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionMSHFlexGrid problem (First-chance exception in ACE.exe (MSHFLXGD.OCX): 0xC0000005: Access Violation.) Pin
lcm311-Nov-05 18:45
lcm311-Nov-05 18:45 
QuestionProblem in using SAFEARRAY Pin
BlrBoy11-Nov-05 18:40
BlrBoy11-Nov-05 18:40 
AnswerRe: Problem in using SAFEARRAY Pin
Mircea Puiu12-Nov-05 3:54
Mircea Puiu12-Nov-05 3:54 
QuestionShowing and hiding Pin
romuzu11-Nov-05 16:56
romuzu11-Nov-05 16:56 
AnswerRe: Showing and hiding Pin
vikas amin11-Nov-05 23:00
vikas amin11-Nov-05 23:00 
AnswerRe: Showing and hiding Pin
Rajesh R Subramanian13-Nov-05 21:39
professionalRajesh R Subramanian13-Nov-05 21:39 
Questionproblem using ADO with C++ Pin
Herr_Ernst11-Nov-05 13:15
Herr_Ernst11-Nov-05 13:15 
AnswerRe: problem using ADO with C++ Pin
Herr_Ernst11-Nov-05 13:33
Herr_Ernst11-Nov-05 13:33 
QuestionMDI Application Pin
masnu11-Nov-05 12:10
masnu11-Nov-05 12:10 
AnswerRe: MDI Application Pin
Cool Ju13-Nov-05 22:31
Cool Ju13-Nov-05 22:31 
GeneralRe: MDI Application Pin
masnu14-Nov-05 2:56
masnu14-Nov-05 2:56 
Questionwhy this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
lucy11-Nov-05 10:39
lucy11-Nov-05 10:39 
AnswerRe: why this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
Cool Ju13-Nov-05 22:52
Cool Ju13-Nov-05 22:52 
GeneralRe: why this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
lucy14-Nov-05 9:07
lucy14-Nov-05 9:07 
AnswerRe: why this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
Cool Ju14-Nov-05 16:53
Cool Ju14-Nov-05 16:53 
GeneralRe: why this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
lucy15-Nov-05 3:44
lucy15-Nov-05 3:44 
QuestionSelective iterator over STL vector. Pin
Maximilien11-Nov-05 10:08
Maximilien11-Nov-05 10:08 
AnswerRe: Selective iterator over STL vector. Pin
Chris Losinger11-Nov-05 10:27
professionalChris Losinger11-Nov-05 10:27 
AnswerRe: Selective iterator over STL vector. Pin
S. Senthil Kumar11-Nov-05 23:24
S. Senthil Kumar11-Nov-05 23:24 
GeneralRe: Selective iterator over STL vector. Pin
Jeremy Thornton12-Nov-05 5:39
Jeremy Thornton12-Nov-05 5:39 
Questionthe knight's tour, solution in cpp Pin
codologyst11-Nov-05 9:06
codologyst11-Nov-05 9:06 
#include <iostream>
#include <iomanip>
using namespace std;


bool Solve(int mat[][8], int x, int y);
void print(int mat[][8]);
void Initmat(int mat[][8]);
bool isvalid(int x, int y);
int counter=1;

int main() {

int mat[8][8];
Initmat(mat);
cout << "Generating solution...";
if (Solve(mat, 0, 0))
print(mat);
else cout << "No solution found" << endl;
return 0;
}

void Initmat(int mat[8][8]) {
for (int x = 0; x < 8; x++)
for (int y = 0; y < 8; y++)
mat[x][y] = 0;
}

void print(int mat[8][8]) {
cout << "Solution found!" << endl;
for (int x = 0;x < 8; x++) {
for (int y = 0; y < 8; y++)
cout << setw(4) << mat[x][y];
cout << endl;
}
}

bool Solve(int mat[8][8], int x, int y)
{
bool done=false;
if (counter == 65)
return true;
if (isvalid(x,y) && (mat[x][y] == 0))
{
mat[x][y] = counter; counter++;
if (!done)done=Solve(mat, x+2, y+1);
if (!done)done=Solve(mat, x+1, y+2);
if (!done)done=Solve(mat, x-1, y+2);
if (!done)done=Solve(mat, x-2, y+1);
if (!done)done=Solve(mat, x-2, y-1);
if (!done)done=Solve(mat, x-1, y-2);
if (!done)done=Solve(mat, x+1, y-2);
if (!done)done=Solve(mat, x+2, y-1);
if (!done){mat[x][y] = 0;counter--;}
}
return done;
}

bool isvalid(int x, int y) {
return ((x >= 0) && (x < 8) && (y >= 0) && (y < 8));
}

www.topsites.co.il
AnswerRe: the knight's tour, solution in cpp Pin
Maximilien11-Nov-05 9:29
Maximilien11-Nov-05 9:29 
QuestionFindFirstPrinterChangeNotification fails on XP laptop. Pin
Flit11-Nov-05 7:35
Flit11-Nov-05 7:35 
QuestionRe: FindFirstPrinterChangeNotification fails on XP laptop. Pin
David Crow11-Nov-05 8:44
David Crow11-Nov-05 8:44 
AnswerRe: FindFirstPrinterChangeNotification fails on XP laptop. Pin
Flit11-Nov-05 19:38
Flit11-Nov-05 19:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.