Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int LeeControl(int, int );
- float LeeMayor (float );
- void CARGA (int [],float [],int );
- BUSQUEDA (int[], int, int);
- main ()
- {int CPROD [10], CODSUL, POS, COD;
- float PU[10];
- CARGA(CPROD,PU,10);
- printf("\n Ingrese codigo del producto a consultar: ");
- scanf("%d", &CODSUL);
- POS = BUSQUEDA(COD, CODSUL, 5);
- if (POS>=0)
- printf("\n Precio %.2f", PU[POS]);
- else
- printf("\n No existe producto");
- }
- //////////////////////
- void CARGA (int VC[],float VP[],int N)
- {int I;
- for (I=0;I<N;I++)
- {printf("\n Ingrese codigo del producto");
- VC[I]=LeeControl(100,999);
- printf("\n Ingrese precio");
- VP[I]=LeeMayor(0);
- }
- }
- ////////////////////
- int LeeControl( int LI, int LS)
- {int DATO;
- do{
- printf("\n Ingrese dato ");
- scanf("%d", &DATO);
- }while(DATO<LI || DATO>LS);
- return(DATO);
- }
- ///////////////////
- float LeeMayor(float VALOR)
- {int DATO;
- do{
- printf("\n Ingrese dato ");
- scanf("%f",&DATO);
- }while(DATO<=VALOR);
- return(DATO);
- }
- //////////////////
- int BUSQUEDA (int V[], int DATO, int N)
- {int I, POSI;
- I=0;
- POSI=1;
- while((POSI==-1)&&(I<N))
- {
- if(V[I]==DATO)
- POSI=I;
- else
- I++;
- return(POSI);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement