Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. typedef struct
  5. {
  6. char codigo[12];
  7. char descripcion[60];
  8. float pu;
  9. float stock;
  10. }materiales;
  11.  
  12. void codigo(materiales mat[1000],char buscar[1000],int cant)
  13. {
  14. int co,b;
  15.  
  16. for(co=0;co<cant;co++)
  17. {
  18. if(strcmp(buscar,mat[co].codigo)==0)
  19. {
  20. printf("La descripcion del articulo seleccionado es: %s",mat[co].descripcion);
  21. printf("\nEl precio unitario del producto es: %f",mat[co].pu);
  22. printf("\nLa cantidad en stock del producto es: %f",mat[co].stock);
  23. b=1;
  24. }
  25. }
  26. if(b!=1)
  27. {
  28. printf("El codigo ingresado no se encuentra registrado");
  29. }
  30. }
  31.  
  32. float total(materiales mat[1000],int cant)
  33. {
  34. float tot=0;
  35. int co;
  36.  
  37. for(co=0;co<cant;co++)
  38. {
  39. tot=tot+(mat[co].pu*mat[co].stock);
  40. }
  41. return tot;
  42. }
  43.  
  44. void stocks(materiales mat[1000],int cant)
  45. {
  46. int co;
  47.  
  48. for(co=0;co<cant;co++)
  49. {
  50. if(mat[co].stock==0)
  51. {
  52. printf("\nEl producto de codigo %s no tiene stock",mat[co].codigo);
  53. }
  54. }
  55. }
  56. int main()
  57. {
  58. int co,cant;
  59. float tot;
  60. char buscar[1000];
  61. materiales mat[1000];
  62. printf("Ingrese la cantidad de materiales a ingresar: ");
  63. scanf("%d",&cant);
  64.  
  65. for(co=0;co<cant;co++)
  66. {
  67. getchar();
  68. printf("Ingrese el codigo: ");
  69. scanf("%[^\n]",mat[co].codigo);
  70. getchar();
  71.  
  72. printf("Ingrese la descripcion: ");
  73. scanf("%[^\n]",mat[co].descripcion);
  74. getchar();
  75.  
  76. printf("Ingrese el precio unitario: ");
  77. scanf("%f",&mat[co].pu);
  78.  
  79. printf("Ingrese la cantidad en stock: ");
  80. scanf("%f",&mat[co].stock);
  81.  
  82. printf("\n");
  83.  
  84. }
  85. getchar();
  86. printf("Ingrese un codigo a buscar: ");
  87. scanf("%[^\n]",buscar);
  88.  
  89. codigo(mat,buscar,cant);
  90.  
  91. tot=total(mat,cant);
  92.  
  93. printf("\nEl total invertido es: %f",tot);
  94.  
  95. stocks(mat,cant);
  96. return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement