viernes, 25 de octubre de 2019

EVALUACIÓN

-Ejercicio 1-

#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <time.h>

using namespace std;

void llenarvector();
void ordenado();
void imprime();

int vec1[20], vec2[20], num1=20, num2;
int n;
int main(){

llenarvector();
ordenado();
imprime();

return 0;
}

void llenarvector(){

srand(time(NULL));
for(int i=0; i<=19; i++){
n=rand()/1000;
vec1[i]=n;
vec2[i]=vec1[i];

}
}

void ordenado(){
for(int i=0; i<num1; i++){
for(int j=0; j<num1-1; j++){
 if (vec2[j]>vec2[j+1]){
 num2=vec2[j];
 vec2[j]=vec2[j+1];
 vec2[j+1]=num2;
}
}
}

}

void imprime(){

cout <<"  IMPRESION DE NUMEROS RANDOM  "<<endl;
for (int i=0; i<=19; i++){
cout<<"\t"<< vec1[i] <<endl;
}
cout<<endl;
cout <<"  ORDENAMIENTO ASCENDENTE (BURBUJA)  "<<endl;
for(int i=0; i<=19; i++){
cout<<"\t"<< vec2[i] <<endl;
}
system("pause");

}


MATRICES

-Programa 20-

#include <stdio.h>
#include <iostream>
#include <windows.h>

using namespace std;

void gotoxy(int x,int y){
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwpos;
dwpos.X=x;
dwpos.Y=y;
SetConsoleCursorPosition(hcon, dwpos);
}
void completado();
void calcular();
void imprimir();

float mat[5][5],x=5,y=8,n=0;

int main(){

completado();
calcular();
imprimir();
}

void completado(){
for(int i=0; i<=3; i++){
for(int j=0; j<=3; j++){
gotoxy(x,y);
cin>>mat[i][j];
x+=5;
}
y+=2;
x=5;
}
}

void calcular(){
mat[0][4]=mat[0][0]+mat[0][1]+mat[0][2]+mat[0][3];
mat[0][4]=mat[0][4]/4;
mat[1][4]=mat[1][0]+mat[1][1]+mat[1][2]+mat[1][3];
mat[1][4]=mat[1][4]/4;
mat[2][4]=mat[2][0]+mat[2][1]+mat[2][2]+mat[2][3];
mat[2][4]=mat[2][4]/4;
mat[3][4]=mat[3][0]+mat[3][1]+mat[3][2]+mat[3][3];
mat[3][4]=mat[3][4]/4;
mat[4][0]=mat[0][0]+mat[1][0]+mat[2][0]+mat[3][0];
mat[4][0]=mat[4][0]/4;
mat[4][1]=mat[0][1]+mat[1][1]+mat[2][1]+mat[3][1];
mat[4][1]=mat[4][1]/4;
mat[4][2]=mat[0][2]+mat[1][2]+mat[2][2]+mat[3][2];
mat[4][2]=mat[4][2]/4;
mat[4][3]=mat[0][3]+mat[1][3]+mat[2][3]+mat[3][3];
mat[4][3]=mat[4][3]/4;
mat[4][4]=mat[0][4]+mat[1][4]+mat[2][4]+mat[3][4];
mat[4][4]=mat[4][4]/4;
system("pause");
system("cls");
system("color F3");
}

void imprimir(){
for(int i=0; i<=4; i++){
for(int j=0; j<=4; j++){
gotoxy(x,y);
cout<<mat[i][j];
x+=5;
}
y+=2;
x=5;
}
}


FACTURA

-Programa 19-

 #include <stdlib.h>
 #include <stdio.h>
 #include <iostream>
 #include <windows.h>

 using namespace std;
char cadena[30];
 int cliente,fac,pre1,pre2,pre3,total,iva;
 void captura();
 void operacion();
 void margen();
 void gotoxy(int x, int y)
 {
     HANDLE hcon;
    hcon=GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X=x;
    dwPos.Y=y;
    SetConsoleCursorPosition(hcon,dwPos);
 }

 int main()
 {
    captura();
    operacion();
    margen();
   
     return 0;
 }

 void captura()
 {
     cout <<endl << endl<<"                         DISTRIBUIDORA ALEMAN                         "<<endl;
     cout <<endl<<endl<<"  CLIENTE:  ";
     gets(cadena);
     cout <<endl<<endl<<"  FACTURA:  " ;
     cin >> fac;
     cout << endl <<"  PRECIO 1:  ";
     cin >> pre1;
     cout << endl <<"  PRECIO 2:  ";
     cin >> pre2;
     cout << endl <<"  PRECIO 3:  ";
     cin >> pre3;
 }

 void operacion()
 {
  total=pre1+pre2+pre3;
  cout << endl << endl<<"  El Total es:  " << total << endl;
 
  iva= total*.16;
  cout << endl <<"  El IVA es:  " << iva << endl;
 }

 void margen ()
{

for(int x=1; x<=79; x++)
{
gotoxy (x,0);
putchar ('*');
gotoxy (x,24);
putchar ('*');
}

for(int y=1; y<=24; y++)
{
gotoxy (0,y);
putchar ('*');
gotoxy (79,y);
putchar ('*');
}
}



viernes, 18 de octubre de 2019

MATRIZ TRANSPUESTA

-Programa 18-

                                                                                                                              (matrices)
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;
int n,m,A[3][4],x=5,y=0;

void captura();
void imprime();
void imprimetraspuesta();

void gotoxy (int x, int y)
{
    HANDLE hcon;
    hcon=GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X=x;
    dwPos.Y=y;
    SetConsoleCursorPosition(hcon,dwPos);
}

int main()
{
captura();
imprime();
imprimetraspuesta();

return 0;
}
void captura(){
    for(int i=0; i<=2; i++){
        for(int j=0; j<=3; j++){
        gotoxy(y,x);
        cin >> A[i][j];
        x+=5;
    }
        y+=2;
        x=5;
    }
    system("pause");
    system("cls");
}

void imprime(){
for(int i=0; i<=2; i++){
        for(int j=0; j<=3; j++){
        gotoxy(y,x);
        cout<< A[i][j];
        x+=5;
    }
        y+=2;
        x=5;
    }
     system("color 3");
    system("pause");
    system("cls");
    //system("Cls");

}

   void imprimetraspuesta(){
    for(int i=0; i<=2; i++){
    for(int j=0; j<=3; j++){
    gotoxy(x,y);
    cout<<A[i][j];
    x+=5;
   }
   y+=2;
   x=5;
   }

   system("pause");
    system("cls");
   }





















PROMEDIO MATRICES 2

-Programa 17-

                                                                                                                           (segunda parte)
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int mat[4][4],f,c,x=5,y=8;

void captura();
void imprime();
void gotoxy (int x, int y)
{
    HANDLE hcon;
    hcon=GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X=x;
    dwPos.Y=y;
    SetConsoleCursorPosition(hcon,dwPos);
}
void captura();
void imprime();

int main()
{
captura();

imprime();

return 0;
}

void captura()
{
for(f=0; f<=3; f++)
        for(c=0; c<=3; c++)
    {
        cout <<"Captura un numero:  " ;
        cin >> mat[f][c];
    }
    system("cls");
   
}

void imprime(){
    for(int f=0; f<=3; f++){
        for(int c=0; c<=3; c++){
        gotoxy(x,y);
        cout << mat[f][c];
        x+=5;
    }
        y+=2;
        x=5;
    }
    system("color 4");
    //system("Cls");
}





















PROMEDIO EN MATRICES

-Programa 16-

                                                                                                                            (segunda parte)
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int mat[6][6],f,c,x=5,y=8;

void captura();
void imprime();
void gotoxy (int x, int y)
{
    HANDLE hcon;
    hcon=GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X=x;
    dwPos.Y=y;
    SetConsoleCursorPosition(hcon,dwPos);
}
void captura();
void imprime();

int main()
{
captura();

imprime();

return 0;
}

void captura()
{
for(f=0; f<=5; f++)
        for(c=0; c<=5; c++)
    {
        cout <<"Captura un numero:  " <<endl;
        cin >> mat[f][c];
    }
    system("cls");
   
}

void imprime(){
    for(int f=0; f<=5; f++){
        for(int c=0; c<=5; c++){
        gotoxy(x,y);
        cout << mat[f][c];
        x+=5;
    }
        y+=2;
        x=5;
    }
    system("color 4");
    //system("Cls");
}









































































EJERCICIO 15

-Programa 15-

                                                                                                                         (segunda parte)
#include <iostream>
#include <windows.h>

using namespace std;
int n,m,A[4][4],x=5,y=0;
void gotoxy (int x, int y)
{
    HANDLE hcon;
    hcon=GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X=x;
    dwPos.Y=y;
    SetConsoleCursorPosition(hcon,dwPos);
}
int main()
{
    for(int i=0; i<=3; i++){
        for(int j=0; j<=3; j++){
        gotoxy(x,y);
        cin >> A[i][j];
        x+=5;
    }
        y+=2;
        x=5;
    }
    system("color 4");
    cout << "HOLA!!!";

    //system("Cls");
    return 0;
}


EJERCICIO MATRICES

-Programa 14-

                                                                                                                        (segunda parte)
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>

using namespace std;

void captura();
void imprime();

int mat[5][5],f,c;
int main()
{
    captura();
    imprime();
    return 0;
}

void captura()
{
    for(f=0; f<=4; f++)
        for(c=0; c<=4; c++)
    {
        cout <<"Captura un numero:  ";
        cin >> mat[f][c];
    }
}
    void imprime()
    {
        for(f=0; f<=4; f++)
            for(c=0; c<=4; c++)
        {
            cout <<" El numero en la posicion " << f << c << "es" << mat[f][c] <<endl;
        }
    }



EJERCICIO 13

-Programa 13-

                                                                                                                             (segunda parte)
  • Generar 30  números RANDOM pero solamente decenas y pedir al usuario que ingrese un numero que este en el rango 10-99 de y buscar el numero dentro del vector e indicar si el numero se encentra dentro del vector o no se encuentra, si se encuentra señalar en que posición esta. Una vez hecho lo anterior, hay que imprimir el vector.
#include <stdlib.h>
#include <time.h>
#include <cstdlib>
#include <stdio.h>
#include <iostream>

using namespace std;
int num,n,i;

int main()
{
    int randi[30],j;
    int ban=0;
    srand(time(NULL));
    
    cout <<endl<<"  °°IMPRESION RANDOM°°  "<<endl;
    for(j=0; j<=29; j++)
     {
         randi[j]=rand()/1000;
         cout<<"\t"<<randi[j]<<endl;
     }
     cout<<"  Ingrese un numero:  ";
     cin>>num;
     {
            for(int i=0; i<=29; i++){
                 if(num==randi[i]){
                        ban=1;
                cout<<endl<<"  El numero  "<< num <<"  se encuentra en la posicion:  "<< " ["<<i+1<<"] "<<endl;
                            break;
                              }
                 else{
                              ban=0;
                              }
                    }
                 if(ban==0){
                      cout<<endl<<endl<<"  El numero no se encuentra en el arreglo  "<<endl;
                 }
     }
     system("PAUSE");
    return 0;

}



EJERCICIO 12

-Programa 12-

                                                                                                                              (segunda parte)
  • Generar 15 números RANDOM y guardarlos en un vector, después los van a ordenar de manera ascendente y los van a pasar al vector 2 (ordenados de manera ascendente) y hay que imprimir los dos vectores.
Método de la Burbuja.

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>

using namespace std;

int vec1[15], vec2[15], num1=15, num2;

int main(){

int n;

srand(time(NULL));

for(int i=0; i<=14; i++){
n=rand()/100;

vec1[i]=n;
vec2[i]=vec1[i];

}
for(int i=0; i<num1; i++){
for(int j=0; j<num1-1; j++){
 if (vec2[j]>vec2[j+1]){
 num2=vec2[j];
 vec2[j]=vec2[j+1];
 vec2[j+1]=num2;
}
}
}

cout <<"  IMPRESION DE NUMEROS RANDOM  "<<endl;
for (int i=0; i<=14; i++){
cout<<"\t"<< vec1[i] <<endl;
}
cout<<endl;
cout <<"  ORDENAMIENTO DE BURBUJA  "<<endl;
for(int i=0; i<=14; i++){
cout<<"\t"<< vec2[i] <<endl;
}
system("pause");
return 0;
}


EJERCICIO 11

-Programa 11-

                                                                                                                      (segunda parte)
  • Generar 20 números RANDOM, guardarlos en un vector y pasarlos a otro vector pero multiplicándolos por 5, cada uno de los números.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

int r,j,h,aleatorio[20],vec1[20],vec2[20];
int main()
{
    srand(time(NULL));
    cout <<"  IMPRESION DE NUMEROS RANDOM  "<<endl;
    for(j=0; j<=19; j++)
    {
        aleatorio[j]=rand();
        cout <<"\t" << aleatorio[j] <<endl;
        vec1[j]=aleatorio[j];
    }

    for(j=0; j<=19; j++)
    {
        vec2[h]=aleatorio[j];
        {
            h++;
        }
        r=vec1[j]*5;
        cout << endl << vec1[j] <<"x" << 5 <<"=" << r;

    }

    return 0;
}


miércoles, 16 de octubre de 2019

EJERCICIO 10

-Programa 10-

                                                                                                                           (segunda parte) 
  • Generar 60 números RANDOM en el rango de 1 al 9999 y los números generados se guardaran en los tres vectores, en el primer vector guardar los números que sean decenas, en el segundo guardar los números centenas y en el tercer vector guardar los números miles.
#include <iostream>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int aleatorio,j,decenas[60],h,centenas[60],i,miles[60],n,randi;
int main()
{
  srand(time(NULL));
  cout<<"IMPRESION DE NUMEROS RANDOM:"<<endl;
  for(j=0;j<=59;j++)
  {
      randi=rand()/10;

        if((randi>=10)&&(randi<=99))
        {
       decenas[h]=randi;
       h++;
        }
       if((randi>=100)&&(randi<999))
        {
       centenas[i]=randi;
       i++;
        }
            if((randi>=1000)&&(randi<9999))
        {

       miles[n]=randi;
       n++;
        }
    }
     cout<<"  Decenas\n";
      for(j=0; j<=h-1; j++)
    {

     cout<<decenas[j]<<endl;
    }
     cout<<"  Centenas\n";
     for(h=0; h<=i-1; h++)
     {
         cout<<centenas[h]<<endl;
     }
     cout<<"  Millares\n";
     for(i=0; i <=n-1; i++)
     {
         cout<<miles[i]<<endl;
     }
  system("PAUSE");
  return 0;
}




EJERCICIO 9

-Programa 9-

                                                                                                                              (segunda parte)
  • Realiza un programa que capture 20 calificaciones en un vector y que las calificaciones aprobatorias las imprima en otro vector y las reprobatorias en otro.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

int calif[20],aprobados[20],reprobados[20],j,h,ap,rp;
int main()
{
    cout <<"  °°CALIFICACIONES°°  "<<endl;
    for(j=0;j<=19;j++)
    {
        cout<<"Captura calificacion:  ";
        cin>>calif[j];
    }

    for(h=0;h<=19;h++)
    {
        if(calif[h]>=7)
        {
           ap[aprobados]=calif[h];
           ap++;
        }
        if(calif[h]<7)
        {
            rp[reprobados]=calif[h];
            rp++;
        }
    }
    cout<<"aprobados"<<endl;
    for(j=0;j<=ap;j++)
    {
        cout<<aprobados[j]<<endl;
    }
    cout<<"reprobados"<<endl;
    for(h=0; h<=rp;h++)
    {
        cout<<reprobados[h]<<endl;
    }

    system("PAUSE");

    return 0;
}


viernes, 11 de octubre de 2019

EJERCICIO 8

-Programa 8-

                                                                                                                         (segunda parte)
  • Realizar un programa con uso de while que imprima los primeros 20 números de la serie de FIBONACCI.
#include <iostream>
#include <stdio.h>
using namespace std;
int n,n1,n2,j;
int main()
{
    n1=1;
    n2=1;
    cout <<n1<<endl;
    cout <<n2<<endl;
        while(n<6765)
    {
        n=n1+n2;
        cout <<n<<endl;;
        n1=n2;
        n2=n;
    }
    return 0;
}


EJERCICIO 7

-Programa 7-

                                                              (segunda parte)

  • Realizar un programa que imprima los primeros números de la serie de FIBONACCI.
#include <iostream>
#include <stdio.h>

using namespace std;
int num,num1,num2,j;

int main()
{
    num1=1;
    num2=1;
    cout <<num1<<endl;
    cout <<num2<<endl;
        for(j=0; j<=17; j++)
    {
        num=num1+num2;
        cout <<num<<endl;;
        num1=num2;
        num2=num;
    }
    return 0;
}




domingo, 6 de octubre de 2019

EJERCICIO 6

-Programa 6-

                                                                                                                           (segunda parte)

  • Realizar un programa que imprima los múltiplos del 5, iniciando por el numero 100.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
int n;
int main()
{
    cout <<"  IMPRIMIR LOS MULTIPLOS DEL 5  "<<endl;
    n=105;
    do
        {
           n=n-5;
           cout <<"\t"<<n<<endl;
        }
        while(n>5);
    system ("pause");

    return 0;
}



EJERCICIO 5

-Programa 5-

                                                                                                                              (segunda parte)

  • Realizar un programa que capture 30 números RANDOM y que mande a imprimir los números mayores a 20.
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <iostream>

using namespace std;

int main()
{

  int randi,j;
  srand(time(NULL));


  cout << "IMPRESION DE NUMEROS RANDOM MAYORES A 20" << endl;


  for (j=1;j<=30;j++)
  {
      randi=rand()/1000;

      if (randi>=20)
      {
          cout << randi << endl;
      }

  }
}



EJERCICIO 4

-Programa 4-

                                                                                                                           (segunda parte)

  • Realizar un programa que capture tres números ingresados por el usuario. El segundo dígito indicara el inicio de la tabla de multiplicar y el tercer dígito indicara el termino de la tabla de multiplicar, por lo cual el primer dígito es el numero del que se mostrara la tabla de multiplicar.  

#include <iostream>
#include <stdio.h>

using namespace std;

int n1,n2,n3,j,res;

int main()

{
   cout << "La tabla a multiplicar es..." << endl;
   cin>> n1;

   cout<<"Ingresa el numero del que iniciara la tabla..."<<endl;
   cin>>n2;

   cout<<"La tabla va terminar en...."<<endl;
   cin>>n3;

if(n2>n3)
   for(j=n2;j>=n3;j--){
       res=j*n1;
     cout<<n1<<"*"<<j<<"="<<res<<endl;
   }
if(n3>n2)
   for(j=n2;j<=n3;j++){
       res=j*n1;
     cout<<n1<<"*"<<j<<"="<<res<<endl;
   }

   return 0;
}





EJERCICIO 3

-Programa 3-

                                                                                                                              (segunda parte)

  • Realizar un programa que capture dos números ingresados por el usuario, se mostrara la tabla de multiplicar del primer numero y el segundo indicara hasta que numero se multiplicara.

#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int tabla,multiplo,j,r;
int main()
{
    cout <<" Ingrese el primer numero:   " ;
    cin >> tabla;
    cout <<" Ingrese el segundo numero:  " ;
    cin >> multiplo;

    for(j=1; j<=multiplo; j++)
        {
       r=tabla*j;
       cout << tabla << "x" << j << "=" << r << endl;
        }

    return 0;
}



EJERCICIO 2

-Programa 2-

                                                                                                                               (segunda parte)

  • Realizar un programa que capture un numero ingresado por el usuario e imprima los siguientes diez números elevados al cuadrado.

#include <iostream>
#include <stdio.h>

using namespace std;

void captura();
void imprimir();
int num,j;
int main()
{
    captura();
    imprimir();
    return 0;
}

void captura()
{
    cout <<" INICIO FUNCION CAPTURA " <<endl;
    cout <<" Ingrese un numero:  ";
    cin >> num;
    cout <<" FIN FUNCION CAPTURA "<<endl;
}

void imprimir()
{
    cout <<endl<<" FUNCION IMPRIMIR "<<endl;
    for(j=num+1; j<=num+11; j++)
        {
        cout <<"\t" << j*j <<endl;
        }
    cout <<" FIN FUNCION IMPRIMIR "<<endl;
}