Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. void g(int *A, int *B, int lim1, int lim2, int lim3, int lim4, int &i, int&j, int&k, int&h, int&lung)
  2. {   int q=0, s=0, t=0, v=0, currentlength=0;
  3.     i=j=k=h=lung=0;
  4.     for(int a =0; a < lim1; a++)
  5.     {   for(int b =0;  b < lim2; b++)
  6.         {   for(int c =0; c < lim3; c++)
  7.             {   for(int d =0; d < lim4; d++)
  8.                 if((*(A + (a*(lim2*lim3*lim4)) + (b*(lim3*lim4)) + (c*(lim4)) + d)) == (*(B + (a*(lim2*lim3*lim4)) + (b*(lim3*lim4)) + (c*(lim4)) + d)))
  9.                 {   cout << (*(A + (a*(lim2*lim3*lim4)) + (b*(lim3*lim4)) + (c*(lim4)) + d)) << " " << (*(B + (a*(lim2*lim3*lim4)) + (b*(lim3*lim4)) + (c*(lim4)) + d));
  10.                     if(a==lim1-1&&b==lim2-1&&c==lim3-1&&d==lim4-1)
  11.                     {   if(currentlength > lung)
  12.                         {   i=q; j=s; k=t; h=v;
  13.                             lung = currentlength;
  14.                             currentlength=0;
  15.                         }
  16.                     }
  17.                     else{   currentlength++; cout << " qui ho incrementato" << endl;
  18.                             if(currentlength==0)
  19.                             q=a; s=b;t=c; v=d;
  20.                         }
  21.                 }
  22.                 else
  23.                 {   cout << (*(A + (a*(lim2*lim3*lim4)) + (b*(lim3*lim4)) + (c*(lim4)) + d)) << " " << (*(B + (a*(lim2*lim3*lim4)) + (b*(lim3*lim4)) + (c*(lim4)) + d));
  24.                     if(currentlength > lung)
  25.                     {   i=q; j=s; k=t; h=v;
  26.                         lung = currentlength; cout << "Qui ho scambiato e azzerato " << endl;
  27.                         currentlength=0;
  28.                     }
  29.                     else currentlength=0; cout << "Qui ho azzerato " << endl;
  30.                 }
  31.                
  32.                
  33.             }
  34.         }
  35.     }      
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement