Guest User

Untitled

a guest
Jul 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <stdio.h>
  4. using namespace std;
  5.  
  6. int sum(int a, int b){
  7.     int wynik;
  8.     wynik = a+b;
  9.    
  10.     return wynik;
  11. }
  12.  
  13. int mul (int a, int b){
  14.     int wynik = a*b;
  15.     return wynik;
  16. }
  17.  
  18. int dif (int a, int b){
  19.     int wynik = a/b;
  20.     return wynik;
  21. }
  22.  
  23. int sub(int a, int b){
  24.     int wynik = a-b;
  25.     return wynik;
  26. }
  27.  
  28. void funCall (int *tab, int x, int (**tabFun)(int, int), int y){
  29.    
  30.     for (int i = 0; i<y; i++){
  31.         cout << (*tabFun[i])(1,2);
  32.     }
  33. }
  34.  
  35.  
  36. int main(int argc, char *argv[])
  37. {
  38.     int i = 4;
  39.    
  40. //  int tab[2] = {1,2};
  41.    
  42.     int (*tabFunPtr[4])(int,int);//jawna deklaracja tablicy wskaznikow na funkcje
  43.     tabFunPtr[0]=mul;
  44.     tabFunPtr[1]=sum;
  45.     tabFunPtr[2]=dif;
  46.     tabFunPtr[3]=sub;
  47.    
  48.     int tab[3] = {1,2};
  49.     funCall(tab,2,tabFunPtr,4);
  50.    
  51.    
  52.    
  53.        
  54.  //   system("PAUSE");
  55.     return EXIT_SUCCESS;
  56. }
Add Comment
Please, Sign In to add comment