Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
Trabajo programación básica.docx

Trabajo programación básica.docx

Ratings: (0)|Views: 6 |Likes:
Published by Jonathan Vera Ruiz

More info:

Published by: Jonathan Vera Ruiz on Dec 10, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

12/10/2013

pdf

text

original

 
PROBLEMA 1
TORRE DE HANOI #include<iostream.h> #include<conio.h> #include<stdlib.h> #include<math.h> void hanoi(int n,char com, char aux, char fin); //función recursiva para describir los movimientos void main(){ char com='A'; char aux='B'; char fin='C'; int n; double N; cout<<"Numeros de discos: ";cin>>n; cout<<"Numero MINIMO de movimientos: "<<pow(2,n)-1<<endl; cout<<"Los movimientos son:"<<endl; hanoi(n,com,aux,fin); getch(); } //desarrollo de la función recursiva void hanoi(int n,char com, char aux, char fin){ if(n==1) cout<<com<<"->"<<fin<<endl; else { hanoi(n-1,com,fin,aux); cout<<com<<"->"<<fin<<endl; hanoi(n-1,aux,com,fin); } }
 
PROBLEMA 2
SERIE #include <iostream.h> #include <conio.h> #include <math.h> void main(){ int n, a, b; double suma, s[10000]; cout<<"Ingrese el valor de a: "; cin>>a; cout<<"Ingrese el valor de b: "; cin>>b; cout<<"Ingrese el numero de terminos: "; cin>>n; suma=0; for(int i=1; i<=n; i++){ double k=i*1.0;
//pasamos al subíndice “i” de e
ntero al real
“k”
 s[i]=pow(sqrt((2*k-1)*a)+2*k*b,1/(2*k))/pow(2*k*a-sqrt((2*k-1)*b),1/(2*k-1)); if(i%2!=0)//condición para un término impar suma+=s[i]; else//para un término par suma-=s[i]; cout<<"s["<<i<<"]="<<suma<<endl; } getch(); }
 
PROBLEMA 3
MÉTODO MONTECARLO PARA HALLAR PI #include <iostream.h> #include <math.h> #include <stdlib.h> #include <conio.h> void main(){ int n, c; cout<<"Ingrese numero de coordenadas: "; cin>>n; double x[10000], y[10000], pi; c=0; for(int i=1; i<=n; i++){ x[i]=1.0 * rand() / (RAND_MAX / 2) - 1; y[i]=1.0 * rand() / (RAND_MAX / 2) - 1; double modulo=sqrt(pow(x[i],2)+pow(x[i],2));//pitágoras para el radio vector if(modulo<=1) c++; } pi=4.0*c/n; cout<<"El valor de pi es igual a: "<<pi<<endl; getch(); }

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->