Está en la página 1de 7

//algoritmos de ordenacion

//metodos
//BURBUJA
#include<iostream>
using namespace std;
const int MAX=20;
void fleerarray(int,float[]);
void fordburbuja(int, float[]);
void fmuestraarray(int,float[]);
void main()

{float array[MAX];
int vcant=0;
cout<<"ingrese la cantidad de datos para el arreglo:";
cin>>vcant;
fleerarray(vcant,array);
fordburbuja(vcant,array);
cout<<"los datos ordenados son:"<<"\n";
fmuestraarray(vcant,array);
}

// implementacion de funciones
void fleerarray (int t, float a[])
{
for(int vc=0;vc<t;vc++)
{
cout<<"ingrese dato: "<<vc+1<<"\t";
cin>> a[vc];
}
system("pause");
}
void fordburbuja(int t, float a[])
{float vtemp=0;
for(int i=0;i<t;i++)
for(int j=t-1; j>=i;j--)
if(a[j-1]>a[j])

{ vtemp=a[j-1];
a[j-1]=a[j];
a[j]=vtemp;
}
}
void fmuestraarray(int t, float a[])
{for(int vc=0; vc<t ; vc++)
cout<<"elemento:"<<vc+1<<"="<<a[vc]<< "\n";
system("pause");
}







//algoritmo de ordenacion
//metodos
//SELECCION
#include<iostream>
using namespace std;
const int MAX=20;
void fleerarray(int,float[]);
void fordseleccion(int, float[]);
void fmuestraarray(int,float[]);
void main()

{float array[MAX];
int vcant=0;
cout<<"ingrese la cantidad de datos para el arreglo:";
cin>>vcant;
fleerarray(vcant,array);
fordseleccion(vcant,array);
cout<<"los datos ordenados son:"<<"\n";
fmuestraarray(vcant,array);
}

// implementacion de funciones
void fleerarray (int t, float a[])
{
for(int vc=0;vc<t;vc++)
{
cout<<"ingrese dato: "<<vc+1<<"\t";
cin>> a[vc];
}
system("pause");
}
void fordseleccion(int t, float a[])
{float vtemp=0;int p=0;
for(int i=0;i<t;i++)
{ p=i;
vtemp=a[i];
for (int j=i+1; j<t-1;j++)
{if(a[j]<vtemp)
{
p=j;
vtemp=a[j];
}
a[p]=a[i];
a[i]=vtemp;
}
}
}
void fmuestraarray(int t, float a[])
{for(int vc=0; vc<t ; vc++)
cout<<"elemento:"<<vc+1<<"="<<a[vc]<< "\n";
system("pause");
}



CANALES
# include <iostream>
using namespace std;
void main ()
{int Vopc = 0;
cout <<"ingrese un nmero de canal\n";
cin>> Vopc;

switch (Vopc)
{
case 2 : cout << "TNP "; break;
case 4 : cout << "gloval "; break;
case 5: cout << "PANAMERICANA "; break;
case 9: cout << "FRECUENCIA LATINA "; break;
case 11: cout << "AMRICA TV "; break;
case 13: cout << "ATV "; break;
default : cout << "canal invlido ";
}
system ("pause");
}

TABLA DE MULTIPLICAR

# include <iostream>
using namespace std;
void main ()

{ for (int vc=0; vc<=15;vc++)
for (int s=1; s<=12;s++)
{
cout<<vc<<"*"<<s<<"="<<vc*s<<"\n";

}
system ( "pause");
}


RELOJ

# include <iostream>
using namespace std;
void main ()

{
for (int h=0; h<=24 ;h++)
for (int m=0; m<=60;m++)
for (int s=0; s<=60;s++)
{
cout<<h<<":"<<m<<":"<<s<<"\n";
system ("cls");
}
system ( "pause");
}


CAMIONES TRABAJANDO

#include<iostream>
using namespace std;
void main()

{
float arrnot[100];
int vcantmaq=0,vnot=0,vmax=0,vsum=0,vkil=0,vpre=0;
//iniciaaizar el arreglo "arrnot"
for(int vc=0;vc<50;vc++)
arrnot[vc]=0;
// ingresar la notas
{ cout<<"Ingrese precio ($) por kilometro recorrido:"<<"\n";
cin>>vpre;
cout<<"Numero de volquetes:"<<"\n";
cin>>vcantmaq;

//ingresar notas
for(int i=0;i<vcantmaq;i++)
{cout<<"Ingrese cantidad de carga(tn) del volquete:"<<i+1<<"\n";
cin>>arrnot[i];
vsum=vsum+arrnot[i];
cout<<"Ingrese el recorrido (km) del volquete:"<<i+1<<"\n";
cin>>arrnot[i];
vkil=vkil+arrnot[i];
}

cout<<"La cantidad de mineral transportado
es:""\t"<<vsum<<"\t""toneladas(tn)"<<"\n";
cout<<"El costo total genarado por la operacion
es:""\t"<<vkil*vpre<<"\t""dolares($)"<<"\n";
}

system("pause");

}











MATRICES

#include <iostream>
using namespace std;

const int t=2;
void leemat(float[t][t]);
void mulmat (float[t][t],float[t][t],float[t][t]);
void presmatrz (float[t][t]);
void main()
{
float vmay=0;
float x[t][t],y[t][t],r[t][t];
leemat(x);
leemat(y);
mulmat(x,y,r);
presmatrz(r);
}
void leemat(float x[t][t])
{
for (int f=0;f<t;f++)
for(int c=0;c<t;c++)
{cout <<"ingrese sus datos en la pocision
:"<<f<<","<<c<<"\n";
cin>>x[f][c];
}
}
void mulmat(float x[t][t],float y [t][t],float r[t][t])
{ for (int f=0;f<t;f++)
for(int c=0;c<t;c++)
r[f][c]=x[f][c]*y[f][c];
cout<<"la multiplicacion de las matrices es:""\n";
}
void presmatrz(float r[t][t])
{ for (int f=0;f<t;f++)
for (int c=0;c<t;c++)
cout<<r[f][c]<<"\t";

system("pause");
}










MINERALES

#include<iostream>
using namespace std;
struct mineral
{ float cdur;
char cnom[50];
};

void main()
{
int vnm=0;
char vminbus[20];
int vnmin;
int vf;
float vdur;
struct mineral amin[50];
cout<<"Ingrese la cantidad de minerales:";
cin>>vnmin;

for (int vc=0; vc<vnmin;vc++)
{
cout<<"nombre:"<<"\t";
cin>>amin[vc].cnom;
cout<<"dureza:"<<"\t";
cin>>amin[vc].cdur;
}
while(vnm==0)
{
cout<<"ingrese nombre a evaluar"<<"\n";
cin>>vminbus;

for(int i=0; i<vnmin; i++)
if(strcmp(vminbus,amin[i].cnom)==0)
vdur=amin[i].cdur;


for(int c=0; c<vnmin;c++)
if(amin[c].cdur>vdur)
cout<<"es alterado por :"<<amin[c].cnom<<"\n";
else
cout<<"el mineral no es alterado por: ""\t"<<amin[c].cnom<<"\n";

cout<<" desea continuar 0; 1 para salir "<<"\a";
cin>>vnm;
}
system("pause");
}





CAMBIO DE BASE

#include <iostream>
using namespace std;
const int t=10;
void main()
{
int arr[t],vnum=0,w=0, vbas=0, vtem=0;
cout <<"Ingrese el numero en base 10"<<"\n";
cin >>vnum;
for (int x=0;x<11;x++)
arr[x]=0;


cout <<"Ingrese la base a convertir"<<"\n";
cin >>vbas;
vtem=vnum;
while(vnum > 0)
{
arr[w]=vnum % vbas;
vnum=vnum / vbas;
w=w+1;
}

cout<<"El numero :"<<vtem<<"\n";
cout<<"Convertido a base :" <<vbas<<"\n";
cout<< "Es :";
for (int i=10;i>=0;i--)
cout<<arr[i];

system("pause");
}

También podría gustarte