Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. int rsq(int x, int y){
  2.      int y1;
  3.      int x1 = x;
  4.      int sumaux = 0;
  5.      for (; x1; x1-= x1&(-x1)){
  6.         y1 = y;
  7.         for(; y1; y1 -= y1&(-y1)){
  8.             sumaux += matrix[x1][y1];
  9.         }
  10.      }
  11.      return sumaux;
  12. }
  13.  
  14. int rsq(int x, int y, int x2, int y2){
  15.      int y1;
  16.      int x1 = x2;
  17.      int sumaux = 0;
  18.      for (; x1; x1-= x1&(-x1)){
  19.         y1 = y;
  20.         for(; y1; y1 -= y1&(-y1)){
  21.             sumaux += matrix[x1][y1];
  22.         }
  23.      }
  24.      return sumaux - ((x == 1 ||y == 1) ? 0 : rsq(x-1, y-1));
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement