Está en la página 1de 5

/*

//UNA FUNCION QUE CALCULA EL AREA Y LONGITUD DE UNA CIRCUNFERENCIA


#include<iostream>
#include<stdlib.h>
#define pi 2*asin(1.0)
#define mensaje "\nOtra Prueba [S][N]"
double longitud(float R);
double area(float R);
using namespace std;
void main(){
float radio;char rpt;
for(;;){system("cls");
cout<<"Ingrese el radio = ";
cin>>radio;
cout<<"El Area = "<<area(radio)<<endl
<<"La longitud es "<<longitud(radio)<<endl
<<mensaje;
cin>>rpt;
if(rpt=='N')break;}
system("pause");
}
double area(float radio){
return(pi*powf(radio,2));
}
double longitud(float radio){
return(pi*2*radio);
}

//funcion void
#include<iostream>
#include<stdlib.h>
#define pi 2*asin(1.0)
#define mensaje "\nOtra Prueba [S][N]"
void longitud();
void area();
float radio;// definicion de variables globales
using namespace std;
void main(){
area();
longitud();
cout<<endl;
system("pause");
}
void area(){
cout<<"Ingrese el radio =";
cin>>radio;
cout<<"El Area = "<<(pi*powf(radio,2));
}
void longitud(){
cout<<"La Longitud es = "<<2*pi*radio;
}

//con direccion(&)
#include<iostream>
#include<stdlib.h>
#define pi 2*asin(1.0)
#define mensaje "\nOtra Prueba [S][N]"

ING. DANIEL OSORIO MALDONADO 1


using namespace std;
void leeR(float &R)//void leeR(float *R)
{cout<<"Ingrese el Radio= ";cin>>R;}//cin>>*R;

double area(float R){


return(pi*powf(R,2));
}
double longitud(float R){
return(2*pi*R);
}

void main(){
float radio;char rpt;
for(;;){system("cls");
leeR(radio);//leeR(&radio);
cout<<"El Area = "<<area(radio)<<endl
<<"La longitud es "<<longitud(radio)<<endl
<<mensaje;
cin>>rpt;
if(rpt=='N')break;}
system("pause");
}

/////////////////////////////////////////////////////////////////
//LA SERIE FIBONACCI
#include<iostream>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
#include<math.h>
using namespace std;

int fibo(int n)
{ if(n == 0 || n == 1)
return n;
else
return fibo(n - 2) + fibo(n - 1);
}
void main()
{ cout<<"\n FIBONACCI \n\n";
int i, num,suma=0 ;
do
{cout<<"Ingrese un numero entero y positivo: ";
cin>>num;
}while(num < 0);
cout<<"\nLa serie es: \n\n\t";
for(i=0; i<num; i++)
{ if(fibo(i)!= 0)
cout<< ", ";
cout<< fibo(i);
suma=suma+fibo(i);
}

cout<<"\nla suma es: "<<suma<<endl;

ING. DANIEL OSORIO MALDONADO 2


system("pause");

}
*/
//////////////////////////
//FIBONACCI_02
#include <iostream>
#include <math.h>
#include <time.h>
using namespace std;
int fibo(int N){
if(N==1)
return 0;
else if(N==2)
return 1;
else
return fibo(N-1)+fibo(N-2);
}
void suma(int N){
int suma=0;
for(int i=1; i<=N;i++){
suma+=fibo(i);
}
cout<<"La suma hasta esa posicion es: "<<suma<<endl;
}
void primos(int N){
cout<<"Los numeros primos hasta esa posicion es o son: ";
for(int j=1;j<=N;j++){
int i=1,cont=0;
while(i<=fibo(j)){
if(fibo(j)%i==0)
cont++;
i++;
}
if(cont==2)
cout<<" "<<fibo(j);
}
cout<<endl;
}
void main(){
int pos;
srand((unsigned)time(NULL));
cout<<"Indique la posision de la serie de fibonacci que desea visualizar: ";
cin>>pos;
if(pos>10){
cout<<"\nEl numero de la serie en esa posicion es: "<<fibo(pos)<<endl;
suma(pos);
primos(pos);

}
else
cout<<"posicion indicada invalida"<<endl;
system("pause");
}

/*

ING. DANIEL OSORIO MALDONADO 3


//////////////////////////////////////////////////////////

// Halla El Area, Las alturas relativas a los lados y el semiperimetro de un


triangulo, de lados L1,L2,L3
#include<iostream>
#include<stdlib.h>
#include<math.h>
#define pi 2*asin(1.0)
#define K 180.0/pi
double area(double L1,double L2,double L3);
double semiper(double L1,double L2,double L3);
void alturas(double L1,double L2,double L3);
void angulos(double L1,double L2,double L3);

using namespace std;


void main(){
double L1,L2,L3;
cout<<"Ingrese el lado del Triangulo L1 = ";cin>>L1;
cout<<"Ingrese el lados del Triangulo L2 = ";cin>>L2;
cout<<"Ingrese el lado del Triangulo L3 = ";cin>>L3;
cout<<"El semiperimetro es "<<semiper(L1,L2,L3)<<endl
<<"El Area es "<<area(L1,L2,L3)<<endl
<<"Las alturas relativas son ";
alturas(L1,L2,L3);
cout<<"Los angulos del triangulo ";
angulos(L1,L2,L3);
cout<<endl;
system("pause");
}
double semiper(double L1,double L2,double L3){
return(L1+L2+L3)/2.0;
}
double area(double L1,double L2,double L3){
double D=semiper(L1,L2,L3),S;
S=D*(D-L1)*(D-L2)*(D-L3);
if(S>0)
return(sqrt(S));
else
cout<<"\n Los lados no Forman un Triangulo No seas ..."<<'\n';
system("pause");
exit(1);
}
void alturas(double L1,double L2,double L3){
double hL1,hL2,hL3;
double D1=area(L1,L2,L3);
hL1=(2/L1)*D1;
hL2=(2/L2)*D1;
hL3=(2/L3)*D1;
cout<<"\nLa alturas = "<<"altura relativa al lado L1 "<<hL1<<endl
<<"La alturas = "<<"altura relativa al lado L2 "<<hL2<<endl
<<"La alturas = "<<"altura relativa al lado L3 "<<hL3<<endl;
}

//Halla los angulos de los vertices del triangulo


void angulos(double L1,double L2,double L3){
double angL1,angL2,angL3;
double D1=area(L1,L2,L3);

ING. DANIEL OSORIO MALDONADO 4


angL1=asin((2.0*D1)/(L1*L2))*K;
angL2=asin((2.0*D1)/(L1*L3))*K;
angL3=asin((2.0*D1)/(L2*L3))*K;
cout<<"\nEl angulo entre L1 y L2 = "<<angL1<<endl
<<"El angulo entre L1 y L3 = "<<angL2<<endl
<<"El angulo entre L2 y L3 = "<<angL3<<endl;
}

#include <iostream>
#inclde<stdlib.h>
#include <math.h>

using namespace std;


void main() {
//Declaracion de variables
double l1,l2,l3,a,b,c,x,y,z;
double s,p;
//entrada
cout<<"ingrese lado l1==>";cin>>l1;
cout<<"ingrese lado l2==>";cin>>l2;
cout<<"ingrese lado l3==>";cin>>l3;
//Proceso
if ((l1<l2+l3)&&(l2<l1+l3)&&(l3<l1+l3))
{p=(l1+l2+l3)*0.5;
s=pow((p-l1)*(p-l2)*(p-l3)*p,0.5);
a=(asin((2*s)/(l1*l2)))*57.2957795;
b=(asin((2*s)/(l1*l3)))*57.2957795;
c=(asin((2*s)/(l2*l3)))*57.2957795;
cout<<"el semiperimetro es==>"<<p<<endl;
cout<<"el area es==>"<<s<<endl;
cout<<"el angulo entre l1 y l2==> "<<a<<endl;
cout<<"el angulo entre l1 y l3==> "<<b<<endl;
cout<<"el angulo entre l2 y l3==> "<<c<<endl;
}
else
cout<<"el triangulo no existe"<<endl;

*/

ING. DANIEL OSORIO MALDONADO 5

También podría gustarte