Advertisement
intsashka

Untitled

May 26th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. //Функция, которая находит минимум из двух чисел.
  5.  
  6. int f1(int a, int b)
  7. {
  8.     return a*b;
  9. }
  10.  
  11. int f2(int a, int b)
  12. {
  13.     return a+b;
  14. }
  15.  
  16. int f3(int a, int b)
  17. {
  18.     return a-b;
  19. }
  20.  
  21. int f4(int a, int b)
  22. {
  23.     return a/b;
  24. }
  25.  
  26. int (*f[6])(int,int) =
  27. {
  28.     &f1,
  29.     &f2,
  30.     NULL,
  31.     &f3,
  32.     NULL,
  33.     &f4
  34. };
  35. int main()
  36. {
  37.     int a, b;
  38.     char op;
  39.     scanf("%d%c%d", &a, &op, &b);
  40.     a = f[op-42](a,b);
  41.     printf("%d\n", a);
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement