pastebin
| #1 paste tool since 2002
create new paste
tools
api
archive
real-time
faq
pastebin
Follow @pastebin
create new paste
trending pastes
sign up
login
my settings
my profile
My Pastes
Public Pastes
Wupload 12 Feb 2012 Pre...
19 sec ago
Untitled
6 sec ago
├┬◀PYXIS CRAFT /D...
15 sec ago
Untitled
12 sec ago
MVC Problem trying to u...
24 sec ago
Untitled
37 sec ago
Untitled
37 sec ago
Untitled
44 sec ago
Layout Width
Share Pastebin
EnDleSs_DaRk
By: a guest | Sep 2nd, 2009 | Syntax:
C++
| Size: 0.86 KB | Hits: 54 | Expires: Never
Download
|
Raw
|
Embed
|
Report abuse
#include <iostream>
//Clase celda
class
objeto
{
private
:
int
valor
;
public
:
//Set tipo de celda
void
decValor
(
)
{
valor
--
;
}
//Imprime el valor
void
impValor
(
)
{
printf
(
"valor:%d
\n
"
,valor
)
;
}
//Constructor de la clase celda
objeto
(
int
quevalor
)
{
valor
=
quevalor
;
}
//Comprueba si es cero
bool
es_cero
(
)
{
if
(
valor
==
0
)
return
true
;
else
return
false
;;
}
//Constructor que copia
objeto
(
const
objeto
&
ref
)
{
// construtor-copia
valor
=
ref.
valor
;
}
}
;
//Funcion chunga y recursiva!
void
recursion
(
objeto actual
)
{
objeto aux
=
actual
;
if
(
actual.
es_cero
(
)
)
printf
(
"Se acabó!!
\n
"
)
;
else
{
actual.
impValor
(
)
;
aux.
decValor
(
)
;
recursion
(
aux
)
;
}
}
//Clase Main
int
main
(
)
{
printf
(
"Prueba de recursividad
\n
"
)
;
printf
(
"=======================
\n
\n
"
)
;
objeto miobjeto1
(
12
)
;
recursion
(
miobjeto1
)
;
return
0
;
}
create new paste
|
create new version of this paste
RAW Paste Data