Advertisement
awsmpshk

function pointer typedef

Sep 5th, 2021
999
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. typedef double (*func)(double);
  5.  
  6. double debounce(func function, double* arr, int size) {
  7.     for (int i = 0; i < size; ++i) {
  8.         std::cout << function(arr[i]) << " ";
  9.     }
  10. }
  11.  
  12. int main() {
  13.     int size;
  14.     std::cin >> size;
  15.     double* arr = new double[size];
  16.    
  17.     for (int i = 0; i < size; ++i) {
  18.         std::cin >> arr[i];
  19.     }
  20.    
  21.     debounce(cos, arr, size);
  22. }
Advertisement
RAW Paste Data Copied
Advertisement