SlideShare a Scribd company logo
#1

void p1(byte n)
{
    if (n > 0 ) {
          p1(n-1);
          ShowMessage(n);
    }
}
#2

void P2(byte n)
{
    if (n > 0) {
          ShowMessage(n);
          P2(n-1);
    }
}
#3

void P3(byte n)
{
    if (n > 0) {
          P3(n-1);
          ShowMessage(n*2-1);
    }
}
#4

void P4(byte n)
{
    if (n > 0) {
          P4(n-1);
          ShowMessage(-n);
    }
}
#5
void P5(Cardinal x, Cardinal &P, Cardinal &I)
{
    if (x<10) {
          if ( x%10 == 2 )
                   { P=x; I=0;}
          else
                   { P=0; I=x;}
    }
    else {
          P5(x/10, P, I);
          if ((x%2)==0)
                P=P*10 + (x%10);
          else
                I=I*10 + (x%10);
    }
}
#6

void P6(Cardinal x, Cardinal y, Cardinal &z)
{
    if (y < 10)
          z = x*10 + y;
    else {
          P6(x,y/10,z);
          z = z*10 + (y%10);
    }
}
#7

void P7(Cardinal &x)
{
    byte d;
    if (x < 10) {
          if ((x%2)==0)
                 {x=0;}
    }
    else {
          d = x % 10;
          x = x / 10;
          P7(x);
          if ((d%2)==1)
                x = x*10 + d;
    }
}
#8

bool P8(Cardinal x)
{
    bool e;
    if (x<10)
          e = true;
    else {
          e = P8(x/10);
          if (e) {
                if ((x%10) < ((x/10)%10))
                      e = false;
          }
    }
    return e;
}
#9

int P9(Cardinal n)
{
     int ndig;
     if (n<10)
          ndig=1;
     else
          ndig=1+P9(n/10);
     return ndig;
}
#10

bool capicua10(Cardinal &nv, Cardinal &a, Cardinal n)
{
    bool capicua;
    nv= (nv*10) + (n%10);
    if (n<10) {
         if (nv==a)
               capicua = true;
         else
               capicua = false;

      }
      else
          capicua = capicua10(nv,a,n/10);
      return capicua;
}
#11

int P11(Cardinal n, Cardinal &may)
{
     int dmay;

      if ((n%10) > may)
            may = n%10;

      if (n<10) {
           dmay = may;
      }
      else
           dmay = P11(n/10, may);
      return dmay;
}
#12

bool P12(int num, int divisor)
{
    if (num < 3) return true;

      if(divisor == 1)
           return true;
      else
           if(num % divisor == 0)
                return false;
           else
                return P12(num, divisor-1);
}
Ejemplo de Implementación


  //Implementado el Ejercicio Nro. 1
  void __fastcall TForm1::btnNro1Click(TObject *Sender)
  {
      AnsiString valor;
      valor=InputBox(quot;Mostrar N numerosquot;,quot;Ingrese numeroquot;,quot;quot;);
      if (valor==quot;quot;) {
            ShowMessage(quot;No ingreso ningun valorquot;);
            return;
      }
      int N = StrToInt(valor);
      P1(N);
  }
!!Fin de la Presentación!!

More Related Content

What's hot

N primo clase programa
N primo clase programaN primo clase programa
N primo clase programa
Leydyca Leydyca
 
Kelompok 2.5
Kelompok 2.5Kelompok 2.5
Kelompok 2.5
1300018075
 
Public class c
Public class cPublic class c
Public class c
onlyhenry
 
Rafaeltorres
RafaeltorresRafaeltorres
Rafaeltorres
rfltorres1
 
(Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++ (Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++ Eli Diaz
 
Ejemplo básico de CUP
Ejemplo básico de CUPEjemplo básico de CUP
Ejemplo básico de CUP
Egdares Futch H.
 
Decimal a hexadecimal
Decimal a hexadecimalDecimal a hexadecimal
Decimal a hexadecimal
BryanChuros
 
Sum2
Sum2Sum2
El Numero Primo
El Numero PrimoEl Numero Primo
El Numero Primo
eccutpl
 
listing output program C
listing output program Clisting output program C
listing output program C
AdjievanGestu
 
Bancocic
BancocicBancocic
Bancocic
edgarflores28
 
Psr calculation matlab code
Psr calculation matlab codePsr calculation matlab code
Psr calculation matlab code
SONURATHI1
 
Rafael vasquez
Rafael vasquezRafael vasquez
Rafael vasquez
Rafael Vasquez
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble, Meita Jayani
 

What's hot (20)

N primo clase programa
N primo clase programaN primo clase programa
N primo clase programa
 
Kelompok 2.5
Kelompok 2.5Kelompok 2.5
Kelompok 2.5
 
Public class c
Public class cPublic class c
Public class c
 
Rafaeltorres
RafaeltorresRafaeltorres
Rafaeltorres
 
(Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++ (Meta 4) ejemplo calcular la mitad de un numero dev c++
(Meta 4) ejemplo calcular la mitad de un numero dev c++
 
Mainfinal
MainfinalMainfinal
Mainfinal
 
Ejemplo básico de CUP
Ejemplo básico de CUPEjemplo básico de CUP
Ejemplo básico de CUP
 
Sine prog
Sine progSine prog
Sine prog
 
Bt c cpp_0021
Bt c cpp_0021Bt c cpp_0021
Bt c cpp_0021
 
Decimal a hexadecimal
Decimal a hexadecimalDecimal a hexadecimal
Decimal a hexadecimal
 
Sum2
Sum2Sum2
Sum2
 
El Numero Primo
El Numero PrimoEl Numero Primo
El Numero Primo
 
listing output program C
listing output program Clisting output program C
listing output program C
 
Bancocic
BancocicBancocic
Bancocic
 
Psr calculation matlab code
Psr calculation matlab codePsr calculation matlab code
Psr calculation matlab code
 
Rafael vasquez
Rafael vasquezRafael vasquez
Rafael vasquez
 
C Program : Sorting : Bubble,
C Program : Sorting : Bubble, C Program : Sorting : Bubble,
C Program : Sorting : Bubble,
 
Passato
PassatoPassato
Passato
 
Par o impar
Par o imparPar o impar
Par o impar
 
Sumas
SumasSumas
Sumas
 

Viewers also liked

Chanel & French Luxury - Marketing lecture 2010
Chanel & French Luxury - Marketing lecture 2010Chanel & French Luxury - Marketing lecture 2010
Chanel & French Luxury - Marketing lecture 2010ashleyed
 
Ashley E Davidson Portfolio
Ashley E Davidson PortfolioAshley E Davidson Portfolio
Ashley E Davidson Portfolioashleyed
 
Gps and conditionals
Gps and conditionalsGps and conditionals
Gps and conditionalsTony Ramirez
 
Principal led change in a web 2
Principal led change in a web 2Principal led change in a web 2
Principal led change in a web 2erie1jenny
 
Leading through Chaos
Leading through ChaosLeading through Chaos
Leading through Chaos
Sanjay Parekh
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
ux singapore
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Stanford GSB Corporate Governance Research Initiative
 

Viewers also liked (7)

Chanel & French Luxury - Marketing lecture 2010
Chanel & French Luxury - Marketing lecture 2010Chanel & French Luxury - Marketing lecture 2010
Chanel & French Luxury - Marketing lecture 2010
 
Ashley E Davidson Portfolio
Ashley E Davidson PortfolioAshley E Davidson Portfolio
Ashley E Davidson Portfolio
 
Gps and conditionals
Gps and conditionalsGps and conditionals
Gps and conditionals
 
Principal led change in a web 2
Principal led change in a web 2Principal led change in a web 2
Principal led change in a web 2
 
Leading through Chaos
Leading through ChaosLeading through Chaos
Leading through Chaos
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Practico Nº 2

  • 1. #1 void p1(byte n) { if (n > 0 ) { p1(n-1); ShowMessage(n); } }
  • 2. #2 void P2(byte n) { if (n > 0) { ShowMessage(n); P2(n-1); } }
  • 3. #3 void P3(byte n) { if (n > 0) { P3(n-1); ShowMessage(n*2-1); } }
  • 4. #4 void P4(byte n) { if (n > 0) { P4(n-1); ShowMessage(-n); } }
  • 5. #5 void P5(Cardinal x, Cardinal &P, Cardinal &I) { if (x<10) { if ( x%10 == 2 ) { P=x; I=0;} else { P=0; I=x;} } else { P5(x/10, P, I); if ((x%2)==0) P=P*10 + (x%10); else I=I*10 + (x%10); } }
  • 6. #6 void P6(Cardinal x, Cardinal y, Cardinal &z) { if (y < 10) z = x*10 + y; else { P6(x,y/10,z); z = z*10 + (y%10); } }
  • 7. #7 void P7(Cardinal &x) { byte d; if (x < 10) { if ((x%2)==0) {x=0;} } else { d = x % 10; x = x / 10; P7(x); if ((d%2)==1) x = x*10 + d; } }
  • 8. #8 bool P8(Cardinal x) { bool e; if (x<10) e = true; else { e = P8(x/10); if (e) { if ((x%10) < ((x/10)%10)) e = false; } } return e; }
  • 9. #9 int P9(Cardinal n) { int ndig; if (n<10) ndig=1; else ndig=1+P9(n/10); return ndig; }
  • 10. #10 bool capicua10(Cardinal &nv, Cardinal &a, Cardinal n) { bool capicua; nv= (nv*10) + (n%10); if (n<10) { if (nv==a) capicua = true; else capicua = false; } else capicua = capicua10(nv,a,n/10); return capicua; }
  • 11. #11 int P11(Cardinal n, Cardinal &may) { int dmay; if ((n%10) > may) may = n%10; if (n<10) { dmay = may; } else dmay = P11(n/10, may); return dmay; }
  • 12. #12 bool P12(int num, int divisor) { if (num < 3) return true; if(divisor == 1) return true; else if(num % divisor == 0) return false; else return P12(num, divisor-1); }
  • 13. Ejemplo de Implementación //Implementado el Ejercicio Nro. 1 void __fastcall TForm1::btnNro1Click(TObject *Sender) { AnsiString valor; valor=InputBox(quot;Mostrar N numerosquot;,quot;Ingrese numeroquot;,quot;quot;); if (valor==quot;quot;) { ShowMessage(quot;No ingreso ningun valorquot;); return; } int N = StrToInt(valor); P1(N); }
  • 14. !!Fin de la Presentación!!