Advertisement
Sinux1

Lab10.cpp

Apr 14th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.     string *thing_list;
  9.     int size;
  10.  
  11.     cout << "How many bands do you listen to?" << endl;
  12.     cin >> size;
  13.     cin.ignore();
  14.  
  15.     // If you do not declare new, on other compilers, it will compile error
  16.     thing_list = new string[size];
  17.     for(int subscript = 0; subscript < size; subscript++)
  18.     {
  19.         cout << "Enter band " << subscript << endl;
  20.         getline(cin, thing_list[subscript]);
  21.     }
  22.  
  23.     cout << "Got it.  Here is the reverse of that list.\n";
  24.     for (int sub = size - 1; sub >= 0; sub--)
  25.     {
  26.         cout << thing_list[sub] << endl;
  27.     }
  28.  
  29.     delete[] thing_list;
  30.  
  31.  
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement