2
Problema 1: Lea 5 números y halle el máximo común divisor con el siguiente formato #include "stdafx.h" #include <iostream> #include <conio.h> using namespace std; int main(){ int n,m,p,q,s,i,r,j,k,l,y=1,x=1,w=1,z=1,v=1,f=1,mcd; cout<< "ingrese el primer numero: " ;cin>>n; cout<< "ingrese el segundo numero:" ;cin>>m; cout<< "ingrese el tercer numero: " ; cin>>p; cout<< "ingrese cuarto numero: " ;cin>>q; cout<< "ingrese quinto numero: " ; cin>>s; cout<< "\n\t N1 \t N2 \t N3 \t N4 \t N5\t FACTORES " <<endl; for (i=1,r=1,j=1,k=1,l=1;i<=n,r<=m,j<=p,k<=q,l<=s;i++,r++,j++,k++,l++){ if (n %i==0,m%r==0,p%j==0,q%k==0,s%l==0){ y=y*i;y=n/i; x=x*r; x=m/r;w=w*j; w=p/j;z=z*k; z=q/k;v=v*l; v=s/l; if ((n%i==0,m%r==0,p%j==0,q%k==0,s%l==0)&&(i==r==j==k==l)) f=i; cout<< "\t" <<y<< "\t" <<x<< "\t" <<w<< "\t" <<z<< "\t" <<v<< "\t" <<f<<endl; }} f=f*i; mcd=f; cout<< "el MCD es :" <<mcd<<endl; _getch(); }

Problema 1

Embed Size (px)

DESCRIPTION

lp

Citation preview

Page 1: Problema 1

Problema 1:

Lea 5 números y halle el máximo común divisor con el siguiente formato

#include "stdafx.h"#include <iostream>#include <conio.h>using namespace std;

int main(){int n,m,p,q,s,i,r,j,k,l,y=1,x=1,w=1,z=1,v=1,f=1,mcd;cout<<"ingrese el primer numero: ";cin>>n;cout<<"ingrese el segundo numero:";cin>>m;cout<<"ingrese el tercer numero: "; cin>>p;cout<<"ingrese cuarto numero: ";cin>>q;

cout<<"ingrese quinto numero: "; cin>>s; cout<< "\n\t N1 \t N2 \t N3 \t N4 \t N5\t FACTORES "<<endl;for(i=1,r=1,j=1,k=1,l=1;i<=n,r<=m,j<=p,k<=q,l<=s;i++,r++,j++,k++,l++){ if(n%i==0,m%r==0,p%j==0,q%k==0,s%l==0){ y=y*i;y=n/i; x=x*r; x=m/r;w=w*j; w=p/j;z=z*k; z=q/k;v=v*l; v=s/l; if((n%i==0,m%r==0,p%j==0,q%k==0,s%l==0)&&(i==r==j==k==l)) f=i;cout<<"\t"<<y<<"\t"<<x<<"\t"<<w<<"\t"<<z<<"\t"<<v<<"\t"<<f<<endl;}}f=f*i;mcd=f;

cout<<"el MCD es :"<<mcd<<endl;_getch();

}

Page 2: Problema 1

Problema 2:

Usando el método de los pasos, lea un intervalo [a,b] y calcule los máximos y mínimos de la función:

f ( x )=cos (x2 )∗e0.1 x