jueves, 21 de julio de 2016

FUNCIÓN NUMEROS PRIMOS

#include <conio.h>
#include <iostream.h>
#include <stdio.h>
#include <math.h>
int funcion_pri( int v1[])
{
int p=0;
 for( int x=0; x<10; x++)
 {   if(v1[x]%2==0)
       {
       p=p+1;
       }
 }
return p;
}
int main()
{
 int v1[10],f=9;
 gotoxy(19,3);cout<<"INSTITUTO TECNOLOGICO SUPERIOR HUAQUILLAS";
gotoxy(32,4);cout<<"...LENIN ZAPATA....";
gotoxy(30,6);cout<<"FUNCION NUMEROS PRIMOS";
gotoxy(10,7);cout<<"INBRESE 10 NUMEROS";
 for( int x=0; x<10; x++)
 {
 gotoxy(15,f);cout<<x+1<<": ";cin>> v1[x];

 f++;
  }
   gotoxy(30,10);cout<<"NUMEROS PRIMOS IMGRESADOS: "<<funcion_pri(v1);
  getch();
  }

FUNCIÓN QUE PERMITE DETERMINAR CUANTOS MENORES, MAYORES Y ADULTOS HAY

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int fun_Adultos(int ed[])
{int suma=0;
  for(int x=0;x<5; x++)
   {
    if(ed[x] > 64)
    {suma =suma +1;}}
   return suma;
}
int fun_mayor(int ed[])
{int sun=0;
 for(int h=0;h<5; h++)
   {if((ed[h] >17)&&(ed[h] <65))
    { sun=sun+1;}
   }return sun;
}
int fun_menores(int ed[])
{int sum=0;
  for(int j=0;j<5; j++)
   {if(ed[j] < 18)
   {sum=sum+1;}}
   return sum;
}
int main()
{ int ed[5],f=10;
gotoxy(19,3);cout<<"INSTITUTO TECNOLOGICO SUPERIOR HUAQUILLAS";
gotoxy(32,4);cout<<"...LENIN ZAPATA....";
gotoxy(6,6);cout<<"FUNCION QUE PERMITE DETERMINAR CUANTOS MENORES, MAYORES Y ADULTOS HAY ";
  gotoxy(5,8);cout<<"\n INGRESE 5 EDADES:  ";
   for(int i=0;i<5; i++)
   {  gotoxy(5,f);cin>>ed[i];f++;}
  cout<<"\n\n ADULTOS    " << fun_Adultos(ed);
  cout<<"\n\n MAYORES    " << fun_mayor(ed);
  cout<<"\n\n MENORES    " << fun_menores(ed);
  getch();
}

miércoles, 20 de julio de 2016

CLEAR UN VECTOR DE 10 ELEMENTOS, PRESENTE UN SEGUNDO VECTOR QUE CONTENGA EL RESULTADO AL CUADRADO DEL PRIMER VECTOR Y PRESENTE EN UN TERSER VECTOR EL RESULTADO AL CUADRADO DEL SEGUNDO VECTOR.

#include <conio.h>
#include <stdio.h>
#include <iostream.h>
//CLEAR UN VECTOR DE 10 ELEMENTOS, PRESENTE UN SEGUNDO VECTOR QUE CONTENGA EL
//RESULTADO AL CUADRADO DEL PRIMER VECTOR Y PRESENTE EN UN TERSER VECTOR EL
//RESULTADO AL CUADRADO DEL SEGUNDO VECTOR.
void main()
{
int v1[10],v2[10],v3[10],f=10,ff=10,ii=1;
gotoxy(5,2); cout<<"INSTITUTO TECNOLOGICO SUPERIOR HUAQUILLAS";
gotoxy(5,3); cout<<"ESTUDIANTE: RUSBERTH LENIN ZAPATA MORALES";
gotoxy(35,5); cout<<"30-JUN-2016";
gotoxy(5,8); cout<<" LLENE EL VECTOR #1";
gotoxy(30,8); cout<<" VECTOR #2";
gotoxy(51,8); cout<<" VECTOR #3";
 for(int i=0;i<=9; i++)
 {
   gotoxy(5,f); cout<<ii<<".-";ii++;
   gotoxy(13,f); cin>>v1[i];
   v2[i]=v1[i]*v1[i];
   v3[i]=v2[i]*v2[i];
   f++;
 }
 for(int i=0;i<=9; i++)
 {
  gotoxy(20,ff);cout<<"------>";
  gotoxy(43,ff);cout<<"------>";
  gotoxy(35,ff);cout<<v2[i];
  gotoxy(55,ff);cout<<v3[i];
  ff++;
 }
 getch ();

}

SUMA DE DOS VECTORES.

#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{float vector1[4],vector2[4], vector3[4];
int i;
gotoxy(19,3);cout<<"INSTITUTO TECNOLOGICO SUPERIOR HUAQUILLAS";
gotoxy(32,4);cout<<"...LENIN ZAPATA....";
gotoxy(27,5);cout<<" SUMA DE DOS VECTORES";
cout << "\n\t INGRESE 4 NUMEROS:  \n";
for ( i=0; i<4; i++)
{
cout << "\t";cin >> vector1[i];
}
cout << "\n\tINGRESE 4 NUMEROS MAS: \n";
for ( i=0; i<4; i++)
{
cout << "\t";cin >> vector2[i];
vector3[i]= vector1[i] + vector2[i];
}
cout << "\n\tLa suma de los dos vectores es: \n";
for (i=0; i<4; i++)
{cout<< "\t"<< vector3[i] << "\n ";
    }
    getch ();
}

FUNCION PARA CALCULAR EL CUBO DE UN NUMERO REAL

# include <iostream.h>
# include <math.h>
# include <conio.h>
# include <stdio.h>
//funcion para calcular el cubo de un numero real
float cubo(float a)
{
float b;
b=pow(a,3);
return b;
}

int main()
{
gotoxy(19,3);cout<<"INSTITUTO TECNOLOGICO SUPERIOR HUAQUILLAS";
gotoxy(32,4);cout<<"...LENIN ZAPATA....";
gotoxy(17,5);cout<<"FUNCION PARA CALCULAR EL CUBO DE UN NUMERO REAL";
float a;
gotoxy(15,8);cout<<"ingrese un numero:";cin>>a;
gotoxy(15,10);cout<<"el cubo del numero ingresado es:"<<cubo(a);
getch();
}

CREAR 2 VECTORES (V) DE 3 ELEMENTOS Y UN TERCER VECTOR QUE CONTENGA EL RESULTADO DE V"B" ELEVADO AL CUBO + V"A" FACTORIAL – 2

#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void main()
{
int v1[3],v2[3],v3[3],r=1,n,num,f=10,fff=25,ff=16, ii=1, iii=1;
gotoxy(14,3);cout<<"INSTITUTO TECNOLOGICO SUPERIOR HUAQUILLAS";
gotoxy(28,4);cout<<"...LENIN ZAPATA....";
gotoxy(31,5); cout<<"30-JUN-2016";
gotoxy(5,8); cout<<" Ingrese 3 numeros:";
gotoxy(48,8); cout<<"Factorial:";
 for(int i=0;i<=2; i++)
 {
  gotoxy(5,f);cout<<ii<<".-";
  gotoxy(13,f);cin>>num;
                for(n=1;n<=num;n++)
   { r=r*n; }
  v1[i]=r;
  gotoxy(32,f);cout<<"------>";
  gotoxy(51,f);cout<<v1[i];
   r=1;f++;ii++;
 }
 gotoxy(5,14); cout<<" Ingrese 3 numeros mas:";
 gotoxy(46,14); cout<<"Elevado al cubo:";
 for(int i=0;i<=2; i++)
 {
   gotoxy(5,ff); cout<<iii<<".-";iii++;
   gotoxy(13,ff); cin>>n;
   v2[i]= n*n*n;
   gotoxy(32,ff);cout<<"------>";
  gotoxy(51,ff);cout<<v2[i];
   ff++;
 }
 gotoxy(27,20); cout<<"TABLA DE RESULTADOS.";
 gotoxy(10,22); cout<<"VECTOR#1";gotoxy(10,23); cout<<"Factorial";
 gotoxy(32,22); cout<<"VECTOR#2";gotoxy(29,23); cout<<"Elevado al cubo";
 gotoxy(53,22); cout<<"VECTOR#3";gotoxy(50,23); cout<<"Fac + cub - 2 =";
 for(int i=0;i<=2; i++)
 {
 v3[i]= v1[i]+v2[i]-2;
 gotoxy(13,fff);cout<<v1[i];
 gotoxy(36,fff);cout<<v2[i];
 gotoxy(56,fff);cout<<v3[i];
 fff++;
 }
 getch ();
}


VECTOR QUE DETERMINA SI UN NUMEROS ES PRIMOS

#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void main()
{
int v[10],a=0, cp=0, f=8;
gotoxy(19,3);cout<<"INSTITUTO TECNOLOGICO SUPERIOR HUAQUILLAS";
gotoxy(32,4);cout<<"...LENIN ZAPATA....";
gotoxy(17,5);cout<<"VECTOR QUE DETERMINA SI UN NUMEROS ES PRIMOS";
gotoxy(5,7);cout<<"Llene el vector";
 for(int i=0; i<=9; i++)
 {
  gotoxy(5,f);cin>> v[i];
  for(int e=1; e<= v[i]; e++)
  {
if(v[i] % e == 0)
   {
   a = a+1;
   }
  }
   if(a == 2)
   {
   cp++;
   gotoxy(7,f);cout<<" <-- numero primo \n";
   }
   f++; a=0;
 }
 f++; gotoxy(6,f);cout<<" Usted ha ingresado "<<cp<<" numeros primos!!.";
  getch();
}