blastermak

Geenaanval2

Apr 19th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. bool geenaanval (int rij, int stand[ ], int welke, int damekolom) {
  2.     // welke = welke dame we huidig mee bezig zijn
  3.     bool veilig = true;
  4.     int hulprij = 1;
  5.     if(welke <= n){
  6.      ydame = rij;
  7.      xdame = stand[rij];
  8.     }//if
  9.     else if(welke > n){
  10.         ydame = (n+2);
  11.         xdame = (n+1);
  12.     }//else if
  13.     while (veilig && (hulprij < rij)) {
  14.         veilig = ((stand[rij] != stand[hulprij]) &&
  15.              ((stand[rij]-stand[hulprij]) != rij-hulprij) &&
  16.              ((stand[rij]-stand[hulprij]) != hulprij-rij));
  17.         if( !veilig && ( (ydame < (n+3)) && (xdame > (n+3)) ){
  18.             veilig = true;
  19.         }//if
  20.         for( int hulpkolom = 1; hulpkolom <= n; hulpkolom++){
  21.             if( (!veilig && (damekolom == stand[hulpkolom])) && ( ((ydame < (n+4)) && (hulpkolom > (n+4)) ) || ( ((ydame > (n+4)) && (hulpkolom < (n+4)) ) ){
  22.                 veilig = true;
  23.             }//if
  24.         }//for
  25.         hulprij++;
  26.     }//while
  27.  
  28.     return veilig;
  29. }//geenaanval
Advertisement
Add Comment
Please, Sign In to add comment