Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <conio.h>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7.  
  8. typedef struct box {
  9.     double high;
  10.     double width;
  11.     double length;
  12.     box *next;
  13. } BOX;
  14.  
  15. void create_a_box(BOX *p) {
  16.     srand(time(NULL));
  17.     p->high = rand()%100+1;
  18.     p->width = rand()%100+1;
  19.     p->length = rand()%100+1;
  20. }
  21. void add_to_the_list(BOX *start) {
  22.     BOX *t1=start;
  23.     while(1) {
  24.         if (t1->next=NULL) break;
  25.         t1 = t1-> next;
  26.     }
  27.     BOX *newbox = new BOX;
  28.     t1 -> next = newbox;
  29.     newbox -> next = NULL;
  30.     create_a_box(newbox);
  31. }
  32. double volume(BOX box) {
  33.     return box.high*box.length*box.width;
  34. }
  35. void display_box(BOX box) {
  36.     cout<<endl<<box.high<<endl<<box.length<<endl<<box.width<<endl;
  37. }
  38. int main()
  39. {
  40.    // BOX box1;
  41.    // create_a_box(&box1);
  42.    // display_box(box1);1
  43.     for (int i;i<10;i++) {
  44.         BOX box[i];
  45.         create_a_box(&box[i]);
  46.         display_box(box[i]);
  47.     }
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement