Click here to Skip to main content
15,894,343 members
Articles / Desktop Programming / MFC

Solve the Pentomino puzzle with C++ and dancing links

Rate me:
Please Sign up or sign in to vote.
4.80/5 (22 votes)
2 Dec 2011CPOL11 min read 121.5K   3.1K   37  
Program to find all the solutions to a Pentomino puzzle.
#pragma once
extern CString PathApplication;

#define ANCHO 6
#define ALTO 10

static void DoEvents()
{
	MSG msg;

	// window message         
	while (PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE))         
	{            
		TranslateMessage(&msg);            
		DispatchMessage(&msg);         
	}      
}
static CString ObtenerEntre(CString CadDatos, CString CadInicio, CString CadFin)
{
	CString CadResultado;
	CString CadBuscar = CadInicio;
	int Pos1 = CadDatos.Find(CadInicio);
	int Pos2 = CadDatos.Find(CadFin, Pos1 + CadInicio.GetLength());
	if (Pos1 < 0 || Pos2 < 0) return "";
	CadResultado = CadDatos.Mid(Pos1 + CadInicio.GetLength(), Pos2 - Pos1 - CadInicio.GetLength());
	return CadResultado.Trim();
}
static CString ObtenerAtributo(CString CadDatos, CString Nombre)
{
	int Pos = CadDatos.Find(Nombre + "=\"");
	int Inicio = Pos + Nombre.GetLength() + 2;
	int PosFin = CadDatos.Find("\"", Inicio);
	return CadDatos.Mid(Inicio, PosFin - Inicio);
}
static double ConvCoord(double A1, double A2, double B1, double B2, double B)
{
	return (A2*(B - B1) + A1*(B2 - B)) / (B2 - B1);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Argentina Argentina
System developer from Argentina.

Programmed in VB 5,6,.NET, C#, Java, PL-SQL, Transac-SQL, C, C++ and even some "calculator" language.

Love to build small, useful applications.
Usually building big and complicated apps based on solid, reliable components.

Hobbies: reading, photography, chess, paddle, running.

Comments and Discussions