Advertisement
Guest User

C# searchGridPos

a guest
Apr 28th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1.  private void findPos(int searchPos , int maxRows, int maxColumns)
  2.         {
  3.             if (searchPos != 0)
  4.             {
  5.                 searchPos += 1;
  6.             }
  7.             int nCount = 0;
  8.  
  9.             int j = 0, i = 0;
  10.  
  11.             for(i = 0; i< maxRows; i++)
  12.             {
  13.                 if(nCount == searchPos)
  14.                 {
  15.                     Console.WriteLine("FOUND!\nRow: " + i + "Col: " + j);
  16.                     break;
  17.                 }
  18.  
  19.                 Console.WriteLine("Row: " + i);
  20.                 nCount++;
  21.  
  22.                 for( j = 0; j < maxColumns; j++)
  23.                 {
  24.                     if (j == 0)
  25.                         continue;
  26.  
  27.                     if (nCount == searchPos)
  28.                     {
  29.                         Console.WriteLine("FOUND!\nRow: " + i + "Col: " + j);
  30.                         break;
  31.                     }
  32.  
  33.                     Console.WriteLine("Col: " + j);
  34.                     nCount++;
  35.                 }
  36.             }
  37.  
  38.             Console.WriteLine(nCount);
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement