Advertisement
Guest User

ej 1o2

a guest
May 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #include <stdio.h>
  2. int LeeControl(int, int );
  3. float LeeMayor (float );
  4. void CARGA (int [],float [],int );
  5. BUSQUEDA (int[], int, int);
  6. main ()
  7. {int CPROD [10], CODSUL, POS, COD;
  8. float PU[10];
  9. CARGA(CPROD,PU,10);
  10. printf("\n Ingrese codigo del producto a consultar: ");
  11. scanf("%d", &CODSUL);
  12. POS = BUSQUEDA(COD, CODSUL, 5);
  13. if (POS>=0)
  14. printf("\n Precio %.2f", PU[POS]);
  15. else
  16. printf("\n No existe producto");
  17. }
  18.  
  19. //////////////////////
  20. void CARGA (int VC[],float VP[],int N)
  21. {int I;
  22. for (I=0;I<N;I++)
  23. {printf("\n Ingrese codigo del producto");
  24. VC[I]=LeeControl(100,999);
  25. printf("\n Ingrese precio");
  26. VP[I]=LeeMayor(0);
  27. }
  28. }
  29.  
  30. ////////////////////
  31. int LeeControl( int LI, int LS)
  32. {int DATO;
  33. do{
  34. printf("\n Ingrese dato ");
  35. scanf("%d", &DATO);
  36. }while(DATO<LI || DATO>LS);
  37. return(DATO);
  38. }
  39. ///////////////////
  40. float LeeMayor(float VALOR)
  41. {int DATO;
  42. do{
  43. printf("\n Ingrese dato ");
  44. scanf("%f",&DATO);
  45. }while(DATO<=VALOR);
  46. return(DATO);
  47. }
  48. //////////////////
  49. int BUSQUEDA (int V[], int DATO, int N)
  50. {int I, POSI;
  51. I=0;
  52. POSI=1;
  53. while((POSI==-1)&&(I<N))
  54. {
  55. if(V[I]==DATO)
  56. POSI=I;
  57. else
  58. I++;
  59. return(POSI);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement