You are on page 1of 3

APLICACIONES RECURSIVAS

UNIVERSIDAD NACIONAL DE TRUJILLO ESCUELA DE INGENIERA DE SISTEMAS

LABORATORIO N 08
APLICACIONES RECURSIVAS
DOCENTE: Dr. LUIS BOY CHAVIL 1. DISEO DEL FORMULARIO

2. CASO Ingresar un nmero entero positivo en la caja de texto y luego mostrar un mensaje indicando si el nmero ingresado tiene 2 o 3 dgitos diferentes. Hacer este proceso con mtodos recursivos!! 3. IMPLEMENTACIN DE LA CLASE ref class OPERACIONES { public: int n; public: int CuentaRep(int, int); int CuentaDif(int); OPERACIONES(void) { } };

Dr. LUIS BOY CHAVIL

Pgina 1

APLICACIONES RECURSIVAS
int OPERACIONES::CuentaRep(int n, int d) { if(n>0) { if(n%10==d) return(1+CuentaRep(n/10, d)); else return(CuentaRep(n/10, d)); } else return(0); } int OPERACIONES::CuentaDif(int n) { if(n>0) { if(CuentaRep(n, n%10)==1) return(1+CuentaDif(n/10)); else return(CuentaDif(n/10)); } else return(0); } 4. IMPLEMENTACIN DEL PROGRAMA PRINCIPAL

private: System::Void BtnVer_Click(System::Object^ sender, System::EventArgs^ { OPERACIONES OP; OP.n=Convert::ToInt32(TxtNumero->Text); if(OP.CuentaDif(OP.n)==2||OP.CuentaDif(OP.n)==3) MessageBox::Show(this, "El nmero "+TxtNumero->Text+" tiene "+OP.CuentaDif(OP.n)+" dgitos diferentes.", "DATO CORRECTO", MessageBoxButtons::OK, MessageBoxIcon::Information, MessageBoxDefaultButton::Button1); else MessageBox::Show(this, "El nmero "+TxtNumero->Text+" solo tiene "+OP.CuentaDif(OP.n)+" dgitos diferentes.", "DATO INCORRECTO", MessageBoxButtons::OK, MessageBoxIcon::Information, MessageBoxDefaultButton::Button1); TxtNumero->Focus(); }

e)

No olvidemos que debemos colocar: #include "OPERACIONES.h" Dr. LUIS BOY CHAVIL Pgina 2

APLICACIONES RECURSIVAS

Dr. LUIS BOY CHAVIL

Pgina 3

You might also like