Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. template <typename T>
  2. void fill(T array[], int size)
  3. {
  4.     char answer;
  5.     while (std::cin.get(answer))
  6.     {
  7.         if (answer == 'Y' || answer == 'y')
  8.         {
  9.             for (int i = 0; i < size; ++i)
  10.             {
  11.                 std::cout << "Array[" << i << "] = ";
  12.                 std::cin >> *array[i];
  13.             }
  14.             break;
  15.         }
  16.         else if (answer == 'N' || answer == 'n')
  17.         {
  18.             for (int i = 0; i < size; ++i)
  19.                 *array[i] = rand() % 20;
  20.             break;
  21.         }
  22.         else
  23.         {
  24.             while (std::cin.get() != '\n')
  25.                 continue;
  26.             std::cout << "Enter correct answer: ";
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement