Programacion
Puntero 2
#include <iostream.h>
void main()
{
int n=75;
int& r=n;
cout <<"n="<<n<<",r"<<r<<endl;
}
Punter 2
#include<iostream.h>
void main()
{
int n=75;
cout <<"n="<<n<<endl;
cout <<"&n="<<&n<<endl;
}
Punter 3
#include <iostream.h>
void main()
{
int n=75;int& r=n;
cout <<"&n="<<&n<<",&r"<<&r<<endl;
}
Puntero 4
#include <stdio.h>
void main()
{
int x;
int *p1,*p2;
p1=&x;
p2=p1;printf("\np1 = %d",p1);
printf("\np2 =%d",p2);
printf("\n %d",&x);
}
potencia
#include <stdio.h>
int Potencia(int base, int exponente)
{
if (exponente==0) //Si el exponente es =0...
return 1; // Se retorna 1
else
return ( base * Potencia(base,exponente-1) );
}
void main()
{
int base=0, exp=0, poten=0;
printf("\nIngresar la base: ");
scanf("%d",&base);printf("\nIngresar el exponente: ");
scanf("%d",&exp);
poten = Potencia(base,exp);
printf("\n\nLa potencia de %d^%d = %d",base,exp,poten);
}
Contar
#include <stdio.h>void numerar(int cima);
int main()
{
numerar(10);
return 0;
}
void numerar(int cima)
{
if (cima > 1)
numerar(cima-1);
printf ("%d " , cima) ;
}
Factor
#include <stdio.h>long factorial(long numero);
main()
{
int a=0;
for (a=1;a<=10;a++)
{
printf("%2d! = %ld\n", a, factorial(a));
}
return 0;
}
long factorial (long numero)
{
if(numero<=1)
return 1;
else
return (numero*factorial(numero-1));
}
Factor 5
#include <stdio.h>
void descender(int cima);
int acu=0;
int main()
{
descender(1);printf("\nLa suma de los 20 números es: %d",acu);
return 0;
}
void descender(int cima)
{
acu += cima;
if (cima < 20)
descender(cima+1);
printf ("%d " , cima) ;
}
Fibonaci
#include...
Regístrate para leer el documento completo.