Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cstdlib>
- #include<cmath>
- using namespace std;
- typedef struct box{
- double height;
- double width;
- double length;
- double volume;
- }BOX;
- double box_volume(BOX box0);
- double biggest_volume(BOX box0[], int sizE, double VOLUME);
- void display_box(BOX box0);
- void create_box(BOX *box0);
- int main()
- {const int sizE=300;
- BOX boxes [sizE];
- for (int i=0;i<sizE;i++){
- create_box(&boxes[i]);
- display_box(boxes[i]);
- }
- biggest_volume(boxes,sizE,1000);
- cout<<"numbers "<<biggest_volume(boxes,sizE,1000);
- return 0;
- }
- double box_volume(BOX box0){
- double volume;
- volume= (box0.length,2)*(box0.height)*(box0.width);
- return volume;
- }
- double biggest_volume(BOX box0[], int sizE, double VOLUME){
- double n;
- for (int i=0;i<sizE;i++){
- if (VOLUME<box_volume(box0[i])){
- n++ ; }
- }
- return n;
- }
- void display_box(BOX box0){
- cout<<"box parameters"<<endl;
- cout<<"length"<<box0.length<<endl;
- cout<<"height"<<box0.height<<endl;
- cout<<"width"<<box0.width<<endl;
- cout<<"volume"<<box_volume(box0)<<endl;
- }
- void create_box(BOX *box0){
- box0->height=rand()%100+1;//100-1 mm;
- box0->length=rand()%100+1;
- box0->width=rand()%100+1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement