SOY NOVATA Y NESECITO AYUDA CON FUNCIONES
NECESITO Q EL SIGUIENTE PROGRAMA USE UNA FUNCION LLAMADA ORDENAR, MI CORREO ES [email protected] Y [email protected]
#include<iostream.h>
#include<iomanip>
int posicion (înt [],int);
int main(){
int A[10],temp,npos=0,clve;
cout<<"clave";
cin>>clave;
cout<<"ingrese elementos del arreglo"<<endl;
for(int x=1,x<10;x++)
{
cout<<"elementos"<<x<<endl;
cin>A[x];
if(posicion)A,clave>0){
cout<<"la ubicacion de "<<clave<<"es :"<<posicion(Aclave)<<endl;
for(int y=1;y<10;y++){
for(int z=1;z<9;z++){
if(A[z]>A[z+1]{
temp=A[z];
A[z]=A[z+1];
A[z+1]=temp;
}
}
cout<<bicacion nueva"<<posicion(A,clave)<<endl;
}
else
cout<<"no existe"<<endl;//la posicion ingresada no existe//
return 0;
}
int posicion(int B[]; int buscar)
{
int posi=0
for(int m=1;m<=10;m++){
if(B[m]=buscar)
posicicon=m;
}
return posi;
}
#include<iostream.h>
#include<iomanip>
int posicion (înt [],int);
int main(){
int A[10],temp,npos=0,clve;
cout<<"clave";
cin>>clave;
cout<<"ingrese elementos del arreglo"<<endl;
for(int x=1,x<10;x++)
{
cout<<"elementos"<<x<<endl;
cin>A[x];
if(posicion)A,clave>0){
cout<<"la ubicacion de "<<clave<<"es :"<<posicion(Aclave)<<endl;
for(int y=1;y<10;y++){
for(int z=1;z<9;z++){
if(A[z]>A[z+1]{
temp=A[z];
A[z]=A[z+1];
A[z+1]=temp;
}
}
cout<<bicacion nueva"<<posicion(A,clave)<<endl;
}
else
cout<<"no existe"<<endl;//la posicion ingresada no existe//
return 0;
}
int posicion(int B[]; int buscar)
{
int posi=0
for(int m=1;m<=10;m++){
if(B[m]=buscar)
posicicon=m;
}
return posi;
}
hola hola
mira fijate que no entiendo lo que hace tu programa
planteamelo y te ayudo
mira fijate que no entiendo lo que hace tu programa
planteamelo y te ayudo
DESARROLLAR UN PROGRAMA Q LLENE UN ARREGLO CON 10 ELEMENTOS POR DATOS INTRODUCIDOS POR EL USUARIO Y HAGA LO SIG
1)Q LEA UN VALOR Y ME INDIQUE LA POSICION Q OCUPA ESE VALOR DENTRO DEL ARREGLO
2)ORDENE EL ARREGLO Y ME MUESTRE LA NUEVA POSICION Q OCUPA ESE VALOR LEIDO
1)Q LEA UN VALOR Y ME INDIQUE LA POSICION Q OCUPA ESE VALOR DENTRO DEL ARREGLO
2)ORDENE EL ARREGLO Y ME MUESTRE LA NUEVA POSICION Q OCUPA ESE VALOR LEIDO
// espero que asi sea gracias
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
const max =10;
typedef int lista[10];
void ingreso(lista);
void ordenar(lista);
int buscar(lista , int);
void verlista(lista vector);
void main()
{
lista vector;
int casilla,dato;
clrscr();
ingreso(vector);
ordenar(vector);
verlista(vector);
cout<<"Ingrese un dato ";
cin >> dato;
casilla=buscar(vector,dato);
if (casilla==-1)
cout<<"dato no encontrado";
else
cout << "el dato esta en la casilla "
<< casilla;
getch();
}
void ingreso(lista vector)
{
for (int x=0;x<max;x++)
{
cout << "ingrese numero casilla ["
<< x
<< "]? ";
cin >> vector[x];
}
}
void verlista(lista vector)
{
cout << "nn";
for (int x=0;x<max;x++)
cout << "casilla "
<< x
<< " = "
<< vector[x]
<< "n";
}
void intercambio(int &a, int&b)
{
int aux=a;
a=b;
b=aux;
}
void ordenar(lista vector)
{
for (int x=0;x<max-1;x++)
for (int y=x+1;y<max;y++)
if (vector[x]>vector[y])
intercambio(vector[x],vector[y]);
}
int buscar(lista vector, int dato)
{
int aux = -1;
for (int x=0;x<max;x++)
if (vector[x]==dato)
aux = x;
return aux;
}
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
const max =10;
typedef int lista[10];
void ingreso(lista);
void ordenar(lista);
int buscar(lista , int);
void verlista(lista vector);
void main()
{
lista vector;
int casilla,dato;
clrscr();
ingreso(vector);
ordenar(vector);
verlista(vector);
cout<<"Ingrese un dato ";
cin >> dato;
casilla=buscar(vector,dato);
if (casilla==-1)
cout<<"dato no encontrado";
else
cout << "el dato esta en la casilla "
<< casilla;
getch();
}
void ingreso(lista vector)
{
for (int x=0;x<max;x++)
{
cout << "ingrese numero casilla ["
<< x
<< "]? ";
cin >> vector[x];
}
}
void verlista(lista vector)
{
cout << "nn";
for (int x=0;x<max;x++)
cout << "casilla "
<< x
<< " = "
<< vector[x]
<< "n";
}
void intercambio(int &a, int&b)
{
int aux=a;
a=b;
b=aux;
}
void ordenar(lista vector)
{
for (int x=0;x<max-1;x++)
for (int y=x+1;y<max;y++)
if (vector[x]>vector[y])
intercambio(vector[x],vector[y]);
}
int buscar(lista vector, int dato)
{
int aux = -1;
for (int x=0;x<max;x++)
if (vector[x]==dato)
aux = x;
return aux;
}
