Advertisement
STANAANDREY

tabelare

Feb 28th, 2023 (edited)
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define LEN_MAX 30
  4.  
  5. void tab(double a, double b, int n, double (*pf)(double)) {
  6.   int sz = b - a;
  7.   double step = 1.0 * sz / n;
  8.   for (double x = a; x <= b; x += step) {
  9.     printf("f(%g)=%g ", x, (*pf)(x));
  10.   }
  11.   puts("");
  12. }
  13.  
  14. int main() {
  15.   //tab(0, 10, 100, sqrt);
  16.   //tab(-10, 10, 20, cos);
  17.   tab(-10, 10, 200, fabs);
  18.   return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement