Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double f1(int);
- int f2(void);
- int f3(void);
- int main() {
- int(*ptr)(void);
- ptr = f2;
- ptr();
- ptr = f3;
- ptr();
- int(*ptMas[])(void) = { f2, f3 };
- ptMas[0]();
- ptMas[1]();
- int mas[3] = { (int)f1, (int)f2, (int)f3 };
- double (*pt1)(int);
- pt1 = (double(*)())mas[0];
- double m = pt1(0);
- printf("\nm= %f", m);
- for (int i = 1; i < 3; i++) {
- ptr = (int(*)())mas[i];
- ptr();
- }
- printf("\n\n");
- double(*ppf)(double);
- ppf = sin;
- printf("sin(0.5) = %f\n", ppf(0.5));
- ppf = cos;
- printf("cos(0.5) = %f\n", ppf(0.5));
- return 0;
- }
- double f1(int a) {
- printf("\ndouble f1(int a)");
- double b = a;
- if (a == 0) return b + 1.0;
- else return 1.0 / b;
- }
- int f2()
- {
- printf("\nint f2(void)");
- return 200;
- }
- int f3() {
- printf("\nint f3(void)");
- return 300;
- }
Add Comment
Please, Sign In to add comment