Advertisement
Guest User

BOX VOLUME

a guest
Jan 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. typedef struct box{
  6. double height;
  7. double width;
  8. double length;
  9. double volume;
  10. }BOX;
  11. double box_volume(BOX box0);
  12. double biggest_volume(BOX box0[], int sizE, double VOLUME);
  13. void display_box(BOX box0);
  14. void create_box(BOX *box0);
  15. int main()
  16. {const int sizE=300;
  17. BOX boxes [sizE];
  18. for (int i=0;i<sizE;i++){
  19. create_box(&boxes[i]);
  20. display_box(boxes[i]);
  21.  
  22. }
  23. biggest_volume(boxes,sizE,1000);
  24. cout<<"numbers "<<biggest_volume(boxes,sizE,1000);
  25. return 0;
  26. }
  27. double box_volume(BOX box0){
  28. double volume;
  29. volume= (box0.length,2)*(box0.height)*(box0.width);
  30. return volume;
  31. }
  32. double biggest_volume(BOX box0[], int sizE, double VOLUME){
  33. double n;
  34. for (int i=0;i<sizE;i++){
  35. if (VOLUME<box_volume(box0[i])){
  36. n++ ; }
  37. }
  38. return n;
  39. }
  40. void display_box(BOX box0){
  41. cout<<"box parameters"<<endl;
  42. cout<<"length"<<box0.length<<endl;
  43. cout<<"height"<<box0.height<<endl;
  44. cout<<"width"<<box0.width<<endl;
  45. cout<<"volume"<<box_volume(box0)<<endl;
  46. }
  47. void create_box(BOX *box0){
  48. box0->height=rand()%100+1;//100-1 mm;
  49. box0->length=rand()%100+1;
  50. box0->width=rand()%100+1;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement