Find position of non | C # implementation to find count of placing non - attacking rooks on the N x N chessboard ; Function to find the count of placing non - attacking rooks on the N x N chessboard ; Count of the Non - attacking rooks ; Printing lexographically smallest configuration ; Driver Code ; Function call
using System ; class P2Placerooks { static void findCountRooks ( int [ ] row , int [ ] col , int n , int k ) { int res = n - k ; Console . WriteLine ( res + " ▁ " ) ; int ri = 0 , ci = 0 ; while ( res -- > 0 ) { while ( ri < k && row [ ri ] == 1 ) { ri ++ ; } while ( ci < k && col [ ci ] == 1 ) { ci ++ ; } Console . WriteLine ( ( ri + 1 ) + " ▁ " + ( ci + 1 ) + " ▁ " ) ; ri ++ ; ci ++ ; } } public static void Main ( String [ ] args ) { int n = 4 ; int k = 2 ; int [ ] row = { 1 , 2 } ; int [ ] col = { 4 , 2 } ; findCountRooks ( row , col , n , k ) ; } }