Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int INF(int *t, int poczatek, int koniec){
  6.     int suma = 0, p1, p2;
  7.    
  8.     for(int i = poczatek; i<koniec; i++)
  9.         for(int k =poczatek; k<koniec; k++)
  10.             suma = suma + t[i] + t[k];
  11.  
  12.     p1 = poczatek + (koniec - poczatek +1)/3;
  13.     p2 = poczatek + 2*(koniec - poczatek +1)/3;
  14.  
  15.     return suma+2*INF(t,poczatek,p1)+6*INF(t,p1,p2)+INF(t,p2,koniec);
  16.  
  17. }
  18.  
  19. int main(){
  20.  
  21.     int tab[10] = {1,2,3,4};
  22.  
  23.     INF(tab, 1,3);
  24.  
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement