Foros del Web » Programación para mayores de 30 ;) » C/C++ »

variable de funcion a otra funcion

Estas en el tema de variable de funcion a otra funcion en el foro de C/C++ en Foros del Web. Hola. estoy haciendo este algoritmo de vectores que ingresando un numero de vectores, halla el valor medio , el menor y mayor valor ordena y ...
  #1 (permalink)  
Antiguo 02/05/2009, 14:09
 
Fecha de Ingreso: enero-2009
Mensajes: 53
Antigüedad: 15 años, 3 meses
Puntos: 1
variable de funcion a otra funcion

Hola. estoy haciendo este algoritmo de vectores que ingresando un numero de vectores, halla el valor medio , el menor y mayor valor ordena y busca, cada operacion tiene una funcion.

lo que necesito es hacer otra funcion que sea de editar el valor del numero buscado, es decir hacer una nueva funcion "editar" y que reemplaze el valor de la variable "bus" de la funcion busquedavector a otro valor dado.

Código a:
Ver original
  1. #include <iostream.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #define max 40
  5.  
  6. void leervector(int x[max],int *dimx);
  7. void mostrarvector(int x[max],int dimx);
  8. int valormenor(int x[max], int dimX);
  9. float valormedio(int x[max],int dimX);
  10. int valormayor(int x[max],int dimx);
  11. void ordenarvector(int x[max],int dimx );
  12. void busquedavector (int x[max],int dimx);
  13. void editarxvalor(int x[max],int dimx,int dato);
  14.  
  15. int main()
  16. {
  17.       int A[max],na;
  18.       leervector(A,&na);
  19.       mostrarvector(A,na);
  20.       valormenor(A,na);
  21.  
  22.       printf("\n");
  23.       int men=valormenor(A,na);
  24.       printf("El menor es: %d\n",men);
  25.       float med=valormedio(A,na);
  26.       printf("El Valor medio es: %0.2f\n",med);
  27.       int may=valormayor(A,na);
  28.       printf("El mayor es: %d\n",may);
  29.       printf("El orden de los datos en forma ascendente es:") ;
  30.       ordenarvector(A,na);
  31.       printf("\n") ;
  32.       system("PAUSE");
  33.       system("cls") ;
  34.       busquedavector(A,na);
  35.       printf("\n") ;
  36.       system("PAUSE");
  37.       return (0);
  38. }
  39. void leervector(int x[max],int *dimx)
  40. {
  41.    int n,i,val;
  42.    printf("Numero de Elementos:");
  43.    scanf("%d",&n);
  44.    if(n<max){
  45.       for(i=0;i<n;i++){printf("Ingrese el valor %d :",i+1);
  46.           scanf("%d",&val);
  47.           x[i]=val;
  48.       }
  49.       *dimx=n;
  50.    }
  51.    else{
  52.       printf("Dimension fuera de rango....");
  53.  
  54.    }
  55. }
  56. void mostrarvector(int x[max],int dimx)
  57. {
  58.  int  i,val;
  59.  for(i=0;i<dimx;i++){
  60.     val=x[i];
  61.     printf("%d,",val);
  62.  
  63.  }
  64. }
  65.  
  66. int valormenor(int x[max], int dimX)
  67. {
  68.  
  69. int menor=x[0];
  70. for(int i=1;i<dimX;i++){
  71. if(x[i]<menor)
  72.  {menor=x[i];}}
  73.  return menor;
  74. }
  75.  
  76. float valormedio(int x[max],int dimX)
  77. {
  78. int suma=0;
  79. for(int i=0;i<dimX;i++){
  80.  suma+=x[i];}
  81.  return(float)suma/dimX;
  82.  
  83. }
  84.  
  85. int valormayor(int x[max],int dimx)
  86. {
  87.   int mayor=x[0];
  88.   for(int i=1;i<dimx;i++){
  89.      if(x[i]>mayor){
  90.         mayor=x[i];
  91.      }
  92.   }
  93.   return mayor;
  94.  
  95.  
  96. }
  97. void ordenarvector(int x[max],int dimx)
  98. {
  99.  int aux,val;
  100.  for(int i=0;i<dimx-1;i++){
  101.      for(int j=i+1;j<dimx;j++){
  102.          if(x[i]>x[j]){
  103.            aux=x[j];
  104.            x[j]=x[i];
  105.            x[i]=aux;
  106.          }
  107.      }
  108.  }
  109.  for(int i=0;i<dimx;i++){
  110.  val=x[i]  ;
  111.  printf("%d,",val);
  112.  }
  113. }
  114.  
  115. void busquedavector (int x[max],int dimx)
  116.  
  117. {
  118.  int aux=0,bus,val;
  119.  printf("Ingrese el numero a buscar:");
  120.  scanf("%d",&bus);
  121.  
  122.  for(int i=0;i<dimx;i++)
  123.  { val=x[i];
  124.     if(bus==val)
  125.    {    printf("El numero en busqueda se encuentra en la casilla : %d,",i+1);
  126.     aux=1;} }
  127.  
  128.    
  129.  if(aux==0)
  130.  { printf("El dato buscado no se encuentra registrado en la base");}
  131.  
  132. }

espero me puedan ayudar.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:55.