ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Maquina de TUring c++ INTENTO

beluxTarea10 de Enero de 2020

1.183 Palabras (5 Páginas)153 Visitas

Página 1 de 5

#include <Windows.h>

#include <string>

using namespace std;

void gotoxy(int x, int y) {//Ancho =80 Alto=25

HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);

COORD dwPos;

dwPos.X = x;

dwPos.Y = y;

SetConsoleCursorPosition(hcon, dwPos);

}

void TextoXY(int x, int y, string texto){

gotoxy(x, y);

cout << texto; //<< "\n";

}

void InforCurso(int Size, bool Visible) {

HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);

CONSOLE_CURSOR_INFO cci;

cci.dwSize = Size;

cci.bVisible = Visible;

SetConsoleCursorInfo(hcon, &cci);

}

void LineaHorizontal(int Hx1, int Hx2, int Hy){

for (int x = Hx1; x <= Hx2; x++)

{

gotoxy(x, Hy);

cout << "-";

}

}

void LineaVertical(int Vx, int Vy1, int Vy2){

for (int y = Vy1; y <= Vy2; y++)

{

gotoxy(Vx, y);

cout << "|";

}

}

void Texto2(int x, int y, char numero){

gotoxy(x, y);

cout << numero; //<< "\n";

}

void Rectangulo(int x1, int y1, int x2, int y2){

LineaHorizontal(x1 + 1, x2 - 1, y1);

LineaHorizontal(x1 + 1, x2 - 1, y2);

LineaVertical(x1, y1 + 1, y2 - 1);

LineaVertical(x2, y1 + 1, y2 - 1);

Texto2(x1, y1, '+');

Texto2(x1, y2, '+');

Texto2(x2, y1, '+');

Texto2(x2, y2, '+');

}

void Rectangulo_limpia(int x1,int y2,int XSixe, int YSixe){

string espacio="";

espacio.append(XSixe,' ');

for(int y=0;y<YSixe;y++){

gotoxy(x1,y2+y);

cout<<espacio;

}

}

void LogError(int x7 , int y7){

TextoXY(x7, y7 , " __________________ ___________ ");

TextoXY(x7, y7+1 , "_/ __ \\_ __ \\_ __ \\/ _ \\_ __ \\");

TextoXY(x7, y7+2 , "\\ ___/| | \\/| | \\( <_> ) | \\/");

TextoXY(x7, y7+3 , " \\___ >__| |__| \\____/|__| ");

TextoXY(x7, y7+4 , " \\/ ");

}

void LogDone(int x7 , int y7){

TextoXY(x7, y7 , " .___ ");

TextoXY(x7, y7+1 , " __| _/____ ____ ____ ");

TextoXY(x7, y7+2 , " / __ |/ _ \\ / \\_/ __ \\ ");

TextoXY(x7, y7+3 , "/ /_/ ( <_> ) | \\ ___/ ");

TextoXY(x7, y7+4 , "\\____ |\\____/|___| /\\___ >");

TextoXY(x7, y7+5 , " \\/ \\/ \\/");

}

void LOGO(int x6, int y6) {

TextoXY(x6, y6, " __ __ ");

TextoXY(x6, y6 + 1, "| |__ ____ _____ ____ | | __________________ ");

TextoXY(x6, y6 + 2, "| | \\ / _ \\ / \\ / _ \\| |/ / _ \\_ __ \\__ \\ ");

TextoXY(x6, y6 + 3, "| Y ( <_> ) Y Y ( <_> ) ( <_> ) | \\// __ \\_");

TextoXY(x6, y6 + 4, "|___| /\\____/|__|_| /\\____/|__|_ \\____/|__| (____ /");

TextoXY(x6, y6 + 5, " \\/ \\/ \\/ \\/ ");

}

//Maquina de Turing

#include <iostream>

#include <conio.h>

#include <stdlib.h>

#include <string.h>

#include <fstream>

/////////////////////////

/////////////////////////

#define Izquierda 75

#define Derecha 77

#define Arriba 72

#define Abajo 80

#define Espacio 32

///////////////////////

using namespace std;

///////STRUCT////////////////////////////////////

struct Condicion{

Condicion *siguiente;

string inserccion;

string escritura;

string movimiento;

string SigEstado;

};

struct Box{

string simbolo;

Box *Der;

Box *Izq;

};

struct Estado{

Estado *Izq;

string Nomb_Est;

Condicion *rul;

};

//*///////////////////////

//

////Variantes Globales//////////////////////////////////////////////

Estado *Nod_Pil=NULL;

Box *CaDna=NULL;

string direccion;

string cad_asig;

string Alfabeto;

string HE;//error

string E;//vacio

string S0;//lado que comienza

bool veri_FIN=true;

bool seguimiento=true, condic=false;

int UbComeX=2,UbComY=8;

//*//////////////////////////////////////////////

void juego();

void disenio();

void NuevoAll();

void crear_Cond(Condicion *&);

void crear_Cad(Box *&,string);

void crear_Estado(Estado *&,string);

void Del_cond(Condicion *&);

void Del_Cad(Box *&);

void Del_Estado(Estado *&);

void Del_Nodos(Estado *&);

void Del_CadAll(Box *&);

void Buq_Est(Estado *&,Estado *&,string , bool );

void Camb_Est(Estado *&,string);

void verificacion(string );

void ingresionTXT();

void ptTXT();

void botones();

void ingresion_cad();

void Buq_Cond(Condicion *&,Condicion *&,string ,string );

void Movimiento(Box *&Ubicacion,Box *&devuelve,string movm);

void almacenamiento(string );

bool verific_acep(Box *&,string);

/////MAIN////////////////////////////////////////////

int main(){

system("cls");

disenio();

LOGO(30,13);

ingresionTXT();

ingresion_cad();

juego();

disenio();

if(seguimiento){

LogDone(30,13);

}else{

LogError(30,13);

}

botones();

}

//////DISENIO////////Mesa de Trabajo =(2,5,116,25)=(2,5,118,30)///////////////////////////////////

/*

void mostLis(Box *a){

if(a==NULL){

cout<<endl;

return;

}else{

cout<<"Pila:"<<a->simbolo<<",";

mostLis(a->siguiente);

}

}

void mostCon(Condicion *a){

if(a==NULL){

return;

}else{

cout<<"Condicion:"<<a->inserccion<< " = "<<a->top<< " = "<<a->insert2<< " = "<<a->insert1<< " = "<<a->paso<<endl;

mostCon(a->siguiente);

}

}

void mostEs(Estado *a){

if(a==NULL){

return;

}else{

cout<<"Estado:"<<a->Nomb_Est<< " = "<<a->estado<<endl;

mostCon(a->rul);

mostLis(a->PilaSimb);

mostEs(a->Izq);

}

}

void MostTOT(){

//system("cls");

mostEs(Nod_Pil);

mostAce(acpeta);

cout<<"ADEMAS"<<endl;

cout<<"Termina:"<<term<<endl;

cout<<"Comienza con:"<<Z0<<endl;

cout<<"La cadena es:"<<cad_asig<<endl;

getch();

}

//*/

void botones(){

Estado *aux=NULL;

Rectangulo(10, 26, 25, 28);//Rectagulo de Menu

TextoXY( 13,27 ,"OTRA CAD.");

Rectangulo(32, 26, 47, 28);//Rectagulo de Otra vez

TextoXY(36, 27, "OTRA Dir.");

Rectangulo(54, 26, 69, 28);//Rectagulo de Menu

TextoXY( 59,27 ,"SALIR.");

bool Salida = false;

int x = 9;//flecha

TextoXY(x, 27, ">");//flecha

do//crea un ciclo para la deteccion de tecla

{

char Ascii = getch();

TextoXY(x, 27, " ");

switch (int(Ascii))

{

case 13:

if (x==9){ //otra cadena

/*

disenio();

Del_PEstad(Nod_Pil);

seguimiento=true;

condic=false;

cad_asig.clear();

Buq_Est(Nod_Pil,aux,"",false);

aux->estado=false;

Camb_Est(Nod_Pil,S0);

Buq_Est(Nod_Pil,aux,"",false);

crear_Pila(aux->PilaSimb,Z0);

Rectangulo_limpia(10,4,200,1);

system("cls");

disenio();

ingresion_cad();

juego();

disenio();

if(seguimiento){

LogDone(30,13);

}else{

LogError(30,13);

}

botones();*/

}else if(x==31){//otra direccion

/*Del_Nodos(Nod_Pil);

S0.clear();

seguimiento=true;

direccion.clear();

cad_asig.clear();

Alfabeto.clear();

Z0.clear();

term.clear();

condic=false;

main();*/

}else if(x==53){

exit(1);

}

break;

//////////////////////////////////////////////////////////////////////////////////////

case -32:// segundo numero teclas especiales ya que las teclas tienen dos valores

char ascii

...

Descargar como (para miembros actualizados) txt (20 Kb) pdf (72 Kb) docx (27 Kb)
Leer 4 páginas más »
Disponible sólo en Clubensayos.com