Advertisement
35657

Untitled

Mar 15th, 2024
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <typename T>
  6. void display(T arr[], int size) {
  7.     for (int i = 0; i < size; i++) {
  8.         cout << arr[i] << " ";
  9.     }
  10.     cout << endl;
  11. }
  12.  
  13. void display(char arr[], int size) {
  14.     for (int i = 0; i < size; i++) {
  15.         cout << arr[i];
  16.     }
  17.     cout << endl;
  18. }
  19.  
  20. int main() {
  21.  
  22.     setlocale(LC_ALL, "ru");
  23.  
  24.     int arr[]{ 1, 3, 7, -4, -2, 4 };
  25.     int size = 6;
  26.     display(arr, size);
  27.  
  28.  
  29.     double arr2[]{ 3.5, 2.5, 3.7, 1.0, 3.3, 7.2 };
  30.     display(arr2, size);
  31.  
  32.     char arr3[]{ 'П','р','и','в','е','т' };
  33.     display(arr3, size);
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement