Advertisement
35657

Untitled

Mar 15th, 2024
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. void display(int arr[], int size) {
  7.     for (int i = 0; i < size; i++) {
  8.         cout << arr[i] << " ";
  9.     }
  10.     cout << endl;
  11. }
  12.  
  13. void display(double arr[], int size) {
  14.     for (int i = 0; i < size; i++) {
  15.         cout << arr[i] << " ";
  16.     }
  17.     cout << endl;
  18. }
  19.  
  20. void display(char arr[], int size) {
  21.     for (int i = 0; i < size; i++) {
  22.         cout << arr[i] << " ";
  23.     }
  24.     cout << endl;
  25. }
  26.  
  27. int main() {
  28.     int arr[]{ 1, 3, 7, -4, -2, 4 };
  29.     int size = 6;
  30.     display(arr, size);
  31.  
  32.  
  33.     // будет ли работать с double?
  34.     double arr2[]{ 3.5, 2.5, 3.7, 1.0, 3.3, 7.2 };
  35.     display(arr2, size);
  36.  
  37.     char arr3[]{ 'a', 'b', 'c', 'd', 'e', 'f'};
  38.     display(arr3, size);
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement