viernes, 25 de octubre de 2019

EVALUACION

                                                                             EXAMEN 



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

using namespace std;
void llenarvector();
void ordenador();
void imprimirvector();


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

   llenarvector();
   ordenador();
   imprimirvector();

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 ordenador()
{

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 imprimirvector()
  {

cout <<"  *-*-*-*-*-*-*-*IMPRESION DE NUMEROS RANDOM *-*-*-*-*-*-*-* "<<endl;
for (int i=0; i<=19; i++){
cout<<"\t"<<"\t"<<  vec1[i] <<endl;
}

cout<<endl;
cout <<"  *-*-*-*ORDENAMIENTO DE MENOR A MAYOR CON METODO BURBUJA*-*-*-* "<<endl;
for(int i=0; i<=19; i++){
cout<<"\t"<<"\t"<< vec2[i] <<endl;
}
system("pause");

}




CÓDIGO 20

                                                         PROGRAMA 20
                                                                                  (matrices)


#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;
}

}




martes, 22 de octubre de 2019

FACTURA

                                                              PROGRAMA 19
                                                                                       (factura)

 #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
using namespace std;
char cadena[30];
void captura();
void imprimir();
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 fac,p1,p2,p3,suma,total,x,y;
int main()
{
captura();
imprimir();
margen();
return 0;
}
void captura()
{
cout<<endl<<endl<<"-----------------DISTRIBUIDORA----------------"<<endl;
cout<<endl<<endl<<"----------------------ALEMAN----------------------"<<endl;
cout<<endl<<endl<<"   CLIENTE:   ";
 gets(cadena);
 cout<<endl<<endl<<"   FACTURA:   ";
 cin>>fac;
cout<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<" "<<"PRECIO"<<endl;
 cout<<endl<<"  PRODUCTO 1:  ";
 cin>>p1;
 cout<<endl<<"  PRODUCTO 2:  ";
 cin>>p2;
 cout<<endl<<"  PRODUCTO 3:  ";
 cin>>p3;
}
void imprimir()
 {
 suma=p1+p2+p3;
 total=suma*0.16;
 cout<<endl<<endl<<"  Total:  "<<suma<<endl;
 cout<<endl<<"  IVA:  "<<total<<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

CÓDIGO 18...

                                                               PROGRAMA 18
                                                                                          (matrices)


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

using namespace std;
int j,i,mat[4][4],x=5,y=8;
void captura();
void imprime();
void imprimerespuesta();
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();
       system("PAUSE");
       system("CLS");
       imprime();
       system("PAUSE");
       imprimerespuesta();
       system("PAUSE");


       return 0;
}

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


      void imprime()
{

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


}
     system("color 3");
    //system("cls");

}

     void imprimerespuesta()
{

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


}
system("color 3");
}





jueves, 17 de octubre de 2019

CÓDIGO 17.

                                                                 PROGRAMA 17
                                                                                            (matrices)


#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.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 ();
    system("PAUSE");
    system("CLS");

    imprime();

    return 0;
}
    void captura ()
{
     for(f=0;f<=3;f++)
     for(c=0;c<=3;c++)
{

     cout<<"captura un numero"<<endl;
     cin>>mat[f][c];
  }

}

    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");

}




CÓDIGO 16.

                                                                     PROGRAMA 16
                                                                                              (matrices)


#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.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 ();
    system("PAUSE");
    system("CLS");

    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];
  }

}

    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");

}



miércoles, 16 de octubre de 2019

CÓDIGO 15.

                                                                  PROGRAMA 15
                                                                                            (matrices)


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

using namespace std;
int n,m,A[4][4],x=5,y=8;
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;
}




CÓDIGO 14.

                                                                    PROGRAMA 14
                                                                                               (matrices)


#include <iostream>
#include<stdio.h>
using namespace std;
int mat [5][5],f,c;
void captura();
void imprime ();
int main()

{
    captura ();
    imprime();
}
    void captura ()
{
     for(f=0;f<=4;f++)
     for(c=0;c<=4;c++){

     cout<<"captura un numero"<<endl;
     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;
}

}




CÓDIGO 13

                                                                         PROGRAMA 13
                                                                                                   (ejercicios)



#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cstdlib>
using namespace std;
int num,n,i;

int main()
{
    int randi[20],j;
    int ban=0;
    srand(time(NULL));
    cout<< " ***IMPRECION RANDOM*** " <<endl;
    for(j=0; j<=29; j++)
     {
         randi[j]=rand()/1000;

         cout<<randi[j]<<endl;
     }
     cout<<"ingrese un numero:"<<endl;
     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;

}




CÓDIGO 12

                                                                PROGRAMA 12
                                                                                          (ejercicios)



*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;
}


viernes, 11 de octubre de 2019

CÓDIGO 11

                                                                     PROGRAMA 11
                                                                                              (ejercicios)

*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 num[20],res[20],h,j,r,vec[20];

int main()
{

    int randi[20],j;
    srand(time(NULL));
    cout<< " ***IMPRECION RANDOM*** " <<endl;
    for(j=0; j<=19; j++)
     {
         randi[j]=rand();

         cout<<randi[j]<<endl;

     }

     cout<< " **NUMEROS MULTIPLICADOS**" <<endl;

     for(h=0; h<=19; h++)
     {
         vec[j]=randi[h]*5;

         cout<<vec[j]<<endl;

     }

    return 0;
}




CÓDIGO 10

                                                             PROGRAMA 10
                                                                                     (ejercicio)

*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;
}




CÓDIGO 9

                                                             PROGRAMA 9
                                                                                    (ejercicio)

*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>

using namespace std;
int j,calificaciones[20],aprobados[20],reprobados[20],h;
int ap=0;
int rp=0;

int main()
{

    cout << "**CALIFICACION**" << endl;

    for(j=0; j<=19; j++)
    {
        cout << "Ingresa la calificacion:  ";
        cin>>calificaciones[j];
    }

    for(h=0; h<=19; h++)
    {
        if(calificaciones[h]>=7)
        {

       aprobados[ap]=calificaciones[h];
       ap++;
        }

    if(calificaciones[h]<7)
    {
        reprobados[rp]=calificaciones[h];
        rp++;
    }
    }

    for(j=0; j<=ap; j++)
    {

        cout<<aprobados[j]<<endl;
    }

     for(h=0; h<=rp; h++)
     {
         cout<<reprobados[h]<<endl;
     }


    return 0;
}



CÓDIGO 8

                                                                 PROGRAMA 8
                                                                                          (ejercicio)

*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 j,j1,j2;


int main()
{

    j1=1;
    j2=1;
    cout<<"FIBONACCI"<<endl;
    cout<<j1<<endl;

    while(j2<=6765)

    {

        cout<<j2<<endl;
        j=j1+j2;
        j1=j2;
        j2=j;
    }


    return 0;

}




CÓDIGO 7

                                                                  PROGRAMA 7
                                                                                          (ejercicio)

*Realizar un programa que imprima los primeros números de la serie de FIBONACCI.


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


using namespace std;
int j,j1,j2,con;

int main()
{

    j1=1;
    j2=1;
    cout<< j1 <<endl;
    cout<< j2 <<endl;
    for(con=1; con<=18 ;con=con+1)
    {
        j=j1+j2;
        cout<< j <<endl;
        j1=j2;
        j2=j;
    }

    return 0;

}




CÓDIGO 6

                                                          PROGRAMA 6
                                                                                (ejercicio)

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


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

using namespace std;
int j=105;

int main()
{
    cout<<"MULTIPLOS DEL 5"<<endl;
    j=105;
    do
    {
        j=j-5;
        cout << j <<endl;
    }

    while (j>5);

    return 0;

}







CÓDIGO 5

                                                                 PROGRAMA 5
                                                                                        (ejercicio)

*Realizar un programa que capture 30 números RANDOM y que mande a imprimir los números mayores a 20.



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

using namespace std;
int j,aleatorio;

int main()

 {
   srand(time(NULL));

   for(j=1;j<=30;j++)
 {

    aleatorio=rand()/1000;
    if(aleatorio>=20)
    cout<<aleatorio<<endl;
    }
 return 0;

    }



CÓDIGO 4

                                                                    PROGRAMA 4
                                                                                          (ejercicios)

*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>
#include <stdlib.h>

using namespace std;
int n1,n2,n3,j,r;

int main()
{
    cout<<"Numero1" << endl;
    cin>>n1;
    cout<<"Numero 2"<<endl;
    cin>>n2;
    cout<<"Numero 3"<<endl;
    cin>>n3;

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

}
}
   system("pause");

    return 0;

}