Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class box{
  5. int x, y;
  6. public:
  7. box(int i, int j){ i = x; j = y; }
  8.  
  9. friend ostream &operator<<(ostream &stream, box o);
  10. };
  11.  
  12.  
  13. ostream &operator<<(ostream &stream, box o)
  14. {
  15. register int i, j;
  16.  
  17. for (i = 0; i < o.x; i++)
  18. stream << "*";
  19.  
  20. stream << "n";
  21. for (j = 1; j < o.y-1; j++){
  22. for (i = 0; i < o.x; i++)
  23. if (i == 0 || i == o.x - 1) stream << "*";
  24. else stream << " ";
  25. stream << "n";
  26. }
  27. for (i = 0; i < o.x; i++)
  28. stream << "*";
  29. stream << "n";
  30.  
  31. return stream;
  32. }
  33.  
  34.  
  35. int main(){
  36. box a(14, 6), b(30, 7), c(40, 5);
  37. cout << a << b << c;
  38.  
  39. return 0;
  40. }
  41.  
  42. box(int i, int j){ i = x; j = y; }
  43.  
  44. box( int i, int j ) : x( i ), y( j ) {}
  45.  
  46. friend ostream &operator<<(ostream &stream, const box &o);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement