dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class Cell { public int x ; public int y ; public Cell ( int x , int y ) { this . x = x ; this . y = y ; } } public class MoveCellPerCellValue { public Boolean isAllCellTraversed ( Cell [ , ] grid ) { Boolean [ , ] visited = new Boolean [ grid . GetLength ( 0 ) , grid . GetLength ( 1 ) ] ; int total = grid . GetLength ( 0 ) * grid . GetLength ( 1 ) ; int startx = grid [ 0 , 0 ] . x ; int starty = grid [ 0 , 0 ] . y ; for ( int i = 0 ; i < total - 2 ; i ++ ) { if ( grid [ startx , starty ] == null ) return false ; if ( visited [ startx , starty ] == true ) return false ; visited [ startx , starty ] = true ; int x = grid [ startx , starty ] . x ; int y = grid [ startx , starty ] . y ; startx = x ; starty = y ; } if ( grid [ startx , starty ] == null ) return true ; return false ; } public static void Main ( String [ ] args ) { Cell [ , ] cell = new Cell [ 3 , 2 ] ; cell [ 0 , 0 ] = new Cell ( 0 , 1 ) ; cell [ 0 , 1 ] = new Cell ( 2 , 0 ) ; cell [ 1 , 0 ] = null ; cell [ 1 , 1 ] = new Cell ( 1 , 0 ) ; cell [ 2 , 0 ] = new Cell ( 2 , 1 ) ; cell [ 2 , 1 ] = new Cell ( 1 , 1 ) ; MoveCellPerCellValue mcp = new MoveCellPerCellValue ( ) ; Console . WriteLine ( mcp . isAllCellTraversed ( cell ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Cell, MoveCellPerCellValue
C# program:
using System ; class GFG { public static bool isPalin ( string str ) { int len = str . Length / 2 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] != str [ str . Length - i - 1 ] ) { return false ; } } return true ; } public static void palindromicPath ( string str , char [ ] [ ] a , int i , int j , int m , int n ) { if ( j < m - 1 i < n - 1 ) { if ( i < n - 1 ) { palindromicPath ( str + a [ i ] [ j ] , a , i + 1 , j , m , n ) ; } if ( j < m - 1 ) { palindromicPath ( str + a [ i ] [ j ] , a , i , j + 1 , m , n ) ; } } else { str = str + a [ n - 1 ] [ m - 1 ] ; if ( isPalin ( str ) ) { Console . WriteLine ( str ) ; } } } public static void Main ( string [ ] args ) { char [ ] [ ] arr = new char [ ] [ ] { new char [ ] { ' a ' , ' a ' , ' a ' , ' b ' } , new char [ ] { ' b ' , ' a ' , ' a ' , ' a ' } , new char [ ] { ' a ' , ' b ' , ' b ' , ' a ' } } ; string str = " " ; palindromicPath ( str , arr , 0 , 0 , 4 , 3 ) ; } }

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int n = 4 ; static int m = 4 ; static int findPossibleMoves ( int [ , ] mat , int p , int q ) { int [ ] X = { 2 , 1 , - 1 , - 2 , - 2 , - 1 , 1 , 2 } ; int [ ] Y = { 1 , 2 , 2 , 1 , - 1 , - 2 , - 2 , - 1 } ; int count = 0 ; for ( int i = 0 ; i < 8 ; i ++ ) { int x = p + X [ i ] ; int y = q + Y [ i ] ; if ( x >= 0 && y >= 0 && x < n && y < m && mat [ x , y ] == 0 ) count ++ ; } return count ; } static public void Main ( ) { int [ , ] mat = { { 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 1 } , { 1 , 1 , 0 , 1 } , { 0 , 1 , 1 , 1 } } ; int p = 2 , q = 2 ; Console . WriteLine ( findPossibleMoves ( mat , p , q ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void printDiagonalSums ( int [ , ] mat , int n ) { int principal = 0 , secondary = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) principal += mat [ i , j ] ; if ( ( i + j ) == ( n - 1 ) ) secondary += mat [ i , j ] ; } } Console . WriteLine ( " Principal ▁ Diagonal : " + principal ) ; Console . WriteLine ( " Secondary ▁ Diagonal : " + secondary ) ; } static public void Main ( ) { int [ , ] a = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } } ; printDiagonalSums ( a , 4 ) ; } }

Accumulator variables: i, j, principal, secondary
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static void printDiagonalSums ( int [ , ] mat , int n ) { int principal = 0 , secondary = 0 ; for ( int i = 0 ; i < n ; i ++ ) { principal += mat [ i , i ] ; secondary += mat [ i , n - i - 1 ] ; } Console . WriteLine ( " Principal ▁ Diagonal : " + principal ) ; Console . WriteLine ( " Secondary ▁ Diagonal : " + secondary ) ; } static public void Main ( ) { int [ , ] a = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } } ; printDiagonalSums ( a , 4 ) ; } }

Accumulator variables: i, principal, secondary
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int data ; public Node next ; public Node child ; } ; static Node newNode ( int data ) { Node newNode = new Node ( ) ; newNode . next = newNode . child = null ; newNode . data = data ; return newNode ; } static Node addSibling ( Node n , int data ) { if ( n == null ) return null ; while ( n . next != null ) n = n . next ; return ( n . next = newNode ( data ) ) ; } static Node addChild ( Node n , int data ) { if ( n == null ) return null ; if ( n . child != null ) return addSibling ( n . child , data ) ; else return ( n . child = newNode ( data ) ) ; } static void traverseTree ( Node root ) { if ( root == null ) return ; Console . Write ( root . data + " ▁ " ) ; if ( root . child == null ) return ; Queue < Node > q = new Queue < Node > ( ) ; Node curr = root . child ; q . Enqueue ( curr ) ; while ( q . Count != 0 ) { curr = q . Peek ( ) ; q . Dequeue ( ) ; while ( curr != null ) { Console . Write ( curr . data + " ▁ " ) ; if ( curr . child != null ) { q . Enqueue ( curr . child ) ; } curr = curr . next ; } } } public static void Main ( String [ ] args ) { Node root = newNode ( 10 ) ; Node n1 = addChild ( root , 2 ) ; Node n2 = addChild ( root , 3 ) ; Node n3 = addChild ( root , 4 ) ; Node n4 = addChild ( n3 , 6 ) ; Node n5 = addChild ( root , 5 ) ; Node n6 = addChild ( n5 , 7 ) ; Node n7 = addChild ( n5 , 8 ) ; Node n8 = addChild ( n5 , 9 ) ; traverseTree ( root ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { public static void printBoundary ( int [ , ] a , int m , int n ) { for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == 0 ) Console . Write ( a [ i , j ] + " ▁ " ) ; else if ( i == m - 1 ) Console . Write ( a [ i , j ] + " ▁ " ) ; else if ( j == 0 ) Console . Write ( a [ i , j ] + " ▁ " ) ; else if ( j == n - 1 ) Console . Write ( a [ i , j ] + " ▁ " ) ; else Console . Write ( " ▁ " ) ; } Console . WriteLine ( " ▁ " ) ; } } static public void Main ( ) { int [ , ] a = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } } ; printBoundary ( a , 4 , 4 ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static long getBoundarySum ( int [ , ] a , int m , int n ) { long sum = 0 ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == 0 ) sum += a [ i , j ] ; else if ( i == m - 1 ) sum += a [ i , j ] ; else if ( j == 0 ) sum += a [ i , j ] ; else if ( j == n - 1 ) sum += a [ i , j ] ; } } return sum ; } static public void Main ( ) { int [ , ] a = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } } ; long sum = getBoundarySum ( a , 4 , 4 ) ; Console . WriteLine ( " Sum ▁ of ▁ boundary " + " ▁ elements ▁ is ▁ " + sum ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSpiral ( int [ , ] mat , int r , int c ) { int i , a = 0 , b = 2 ; int low_row = ( 0 > a ) ? 0 : a ; int low_column = ( 0 > b ) ? 0 : b - 1 ; int high_row = ( ( a + 1 ) >= r ) ? r - 1 : a + 1 ; int high_column = ( ( b + 1 ) >= c ) ? c - 1 : b + 1 ; while ( ( low_row > 0 - r && low_column > 0 - c ) ) { for ( i = low_column + 1 ; i <= high_column && i < c && low_row >= 0 ; ++ i ) Console . Write ( mat [ low_row , i ] + " ▁ " ) ; low_row -= 1 ; for ( i = low_row + 2 ; i <= high_row && i < r && high_column < c ; ++ i ) Console . Write ( mat [ i , high_column ] + " ▁ " ) ; high_column += 1 ; for ( i = high_column - 2 ; i >= low_column && i >= 0 && high_row < r ; -- i ) Console . Write ( mat [ high_row , i ] + " ▁ " ) ; high_row += 1 ; for ( i = high_row - 2 ; i > low_row && i >= 0 && low_column >= 0 ; -- i ) Console . Write ( mat [ i , low_column ] + " ▁ " ) ; low_column -= 1 ; } Console . WriteLine ( ) ; } static public void Main ( ) { int [ , ] mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int r = 3 , c = 3 ; printSpiral ( mat , r , c ) ; } }

Accumulator variables: high_column, high_row, low_column, low_row
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int N = 3 ; static void interchangeDiagonals ( int [ , ] array ) { for ( int i = 0 ; i < N ; ++ i ) if ( i != N / 2 ) { int temp = array [ i , i ] ; array [ i , i ] = array [ i , N - i - 1 ] ; array [ i , N - i - 1 ] = temp ; } for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) Console . Write ( array [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( ) { int [ , ] array = { { 4 , 5 , 6 } , { 1 , 2 , 3 } , { 7 , 8 , 9 } } ; interchangeDiagonals ( array ) ; } }

Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int difference ( int [ , ] arr , int n ) { int d1 = 0 , d2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j ) d1 += arr [ i , j ] ; if ( i == n - j - 1 ) d2 += arr [ i , j ] ; } } return Math . Abs ( d1 - d2 ) ; } public static void Main ( ) { int n = 3 ; int [ , ] arr = { { 11 , 2 , 4 } , { 4 , 5 , 6 } , { 10 , 8 , - 12 } } ; Console . Write ( difference ( arr , n ) ) ; } }

Accumulator variables: d1, d2, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int difference ( int [ , ] arr , int n ) { int d1 = 0 , d2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { d1 += arr [ i , i ] ; d2 += arr [ i , n - i - 1 ] ; } return Math . Abs ( d1 - d2 ) ; } public static void Main ( ) { int n = 3 ; int [ , ] arr = { { 11 , 2 , 4 } , { 4 , 5 , 6 } , { 10 , 8 , - 12 } } ; Console . Write ( difference ( arr , n ) ) ; } }

Accumulator variables: d1, d2, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100 ; static void spiralFill ( int m , int n , int [ , ] a ) { int val = 1 ; int k = 0 , l = 0 ; while ( k < m && l < n ) { for ( int i = l ; i < n ; ++ i ) { a [ k , i ] = val ++ ; } k ++ ; for ( int i = k ; i < m ; ++ i ) { a [ i , n - 1 ] = val ++ ; } n -- ; if ( k < m ) { for ( int i = n - 1 ; i >= l ; -- i ) { a [ m - 1 , i ] = val ++ ; } m -- ; } if ( l < n ) { for ( int i = m - 1 ; i >= k ; -- i ) { a [ i , l ] = val ++ ; } l ++ ; } } } public static void Main ( ) { int m = 4 , n = 4 ; int [ , ] a = new int [ MAX , MAX ] ; spiralFill ( m , n , a ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { Console . Write ( a [ i , j ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; } } }

Accumulator variables: i, j, k, l, m, n, val
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printTreeEdges ( int [ ] prufer , int m ) { int vertices = m + 2 ; int [ ] vertex_set = new int [ vertices ] ; for ( int i = 0 ; i < vertices ; i ++ ) vertex_set [ i ] = 0 ; for ( int i = 0 ; i < vertices - 2 ; i ++ ) vertex_set [ prufer [ i ] - 1 ] += 1 ; Console . Write ( " set ( G ) is : " int j = 0 ; for ( int i = 0 ; i < vertices - 2 ; i ++ ) { for ( j = 0 ; j < vertices ; j ++ ) { if ( vertex_set [ j ] == 0 ) { vertex_set [ j ] = - 1 ; Console . Write ( " ( " + ( j + 1 ) + " , ▁ " + prufer [ i ] + " ) ▁ " ) ; vertex_set [ prufer [ i ] - 1 ] -- ; break ; } } } j = 0 ; for ( int i = 0 ; i < vertices ; i ++ ) { if ( vertex_set [ i ] == 0 && j == 0 ) { Console . Write ( " ( " + ( i + 1 ) + " , ▁ " ) ; j ++ ; } else if ( vertex_set [ i ] == 0 && j == 1 ) Console . Write ( ( i + 1 ) + " ) STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ ] prufer = { 4 , 1 , 3 , 4 } ; int n = prufer . Length ; printTreeEdges ( prufer , n ) ; } }

Index/key variables: i, j, vertices
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static void maxMin ( int [ , ] arr , int n ) { int min = + 2147483647 ; int max = - 2147483648 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= n / 2 ; j ++ ) { if ( arr [ i , j ] > arr [ i , n - j - 1 ] ) { if ( min > arr [ i , n - j - 1 ] ) min = arr [ i , n - j - 1 ] ; if ( max < arr [ i , j ] ) max = arr [ i , j ] ; } else { if ( min > arr [ i , j ] ) min = arr [ i , j ] ; if ( max < arr [ i , n - j - 1 ] ) max = arr [ i , n - j - 1 ] ; } } } Console . Write ( " Maximum ▁ = ▁ " + max + " , ▁ Minimum ▁ = ▁ " + min ) ; } static public void Main ( ) { int [ , ] arr = { { 5 , 9 , 11 } , { 25 , 0 , 14 } , { 21 , 6 , 4 } } ; maxMin ( arr , 3 ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static void antiSpiralTraversal ( int m , int n , int [ ] [ ] a ) { int i , k = 0 , l = 0 ; Stack < int > stk = new Stack < int > ( ) ; while ( k <= m && l <= n ) { for ( i = l ; i <= n ; ++ i ) { stk . Push ( a [ k ] [ i ] ) ; } k ++ ; for ( i = k ; i <= m ; ++ i ) { stk . Push ( a [ i ] [ n ] ) ; } n -- ; if ( k <= m ) { for ( i = n ; i >= l ; -- i ) { stk . Push ( a [ m ] [ i ] ) ; } m -- ; } if ( l <= n ) { for ( i = m ; i >= k ; -- i ) { stk . Push ( a [ i ] [ l ] ) ; } l ++ ; } } while ( stk . Count > 0 ) { Console . Write ( stk . Peek ( ) + " ▁ " ) ; stk . Pop ( ) ; } } public static void Main ( string [ ] args ) { int [ ] [ ] mat = new int [ ] [ ] { new int [ ] { 1 , 2 , 3 , 4 , 5 } , new int [ ] { 6 , 7 , 8 , 9 , 10 } , new int [ ] { 11 , 12 , 13 , 14 , 15 } , new int [ ] { 16 , 17 , 18 , 19 , 20 } } ; antiSpiralTraversal ( mat . Length - 1 , mat [ 0 ] . Length - 1 , mat ) ; } }

Index/key variables: i, k, l, m, n
Accumulator variables: k, l, m, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public const int N = 5 ; public const int M = 5 ; public static int minOperation ( bool [ ] [ ] arr ) { int ans = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { for ( int j = M - 1 ; j >= 0 ; j -- ) { if ( arr [ i ] [ j ] == false ) { ans ++ ; for ( int k = 0 ; k <= i ; k ++ ) { for ( int h = 0 ; h <= j ; h ++ ) { if ( arr [ k ] [ h ] == true ) { arr [ k ] [ h ] = false ; } else { arr [ k ] [ h ] = true ; } } } } } } return ans ; } public static void Main ( string [ ] args ) { bool [ ] [ ] mat = new bool [ ] [ ] { new bool [ ] { false , false , true , true , true } , new bool [ ] { false , false , false , true , true } , new bool [ ] { false , false , false , true , true } , new bool [ ] { true , true , true , true , true } , new bool [ ] { true , true , true , true , true } } ; Console . WriteLine ( minOperation ( mat ) ) ; } }

Index/key variables: h, i, j, k
Accumulator variables: ans, h, i, j, k
Iterator variables: h, i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int ROW = 3 ; static int COL = 3 ; static void transpose ( int [ , ] transpose_matrix , int [ , ] matrix ) { for ( int i = 0 ; i < ROW ; i ++ ) for ( int j = 0 ; j < COL ; j ++ ) transpose_matrix [ j , i ] = matrix [ i , j ] ; } static bool check ( int [ , ] transpose_matrix , int [ , ] matrix ) { for ( int i = 0 ; i < ROW ; i ++ ) for ( int j = 0 ; j < COL ; j ++ ) if ( matrix [ i , j ] != - transpose_matrix [ i , j ] ) return false ; return true ; } static void printMatrix ( int [ , ] matrix ) { for ( int i = 0 ; i < ROW ; i ++ ) { for ( int j = 0 ; j < COL ; j ++ ) Console . Write ( matrix [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( ) { int [ , ] matrix = { { 0 , 5 , - 4 } , { - 5 , 0 , 1 } , { 4 , - 1 , 0 } , } ; int [ , ] transpose_matrix = new int [ ROW , COL ] ; transpose ( transpose_matrix , matrix ) ; Console . WriteLine ( " Transpose ▁ matrix : ▁ " ) ; printMatrix ( transpose_matrix ) ; if ( check ( transpose_matrix , matrix ) ) Console . WriteLine ( " Skew ▁ Symmetric ▁ Matrix " ) ; else Console . WriteLine ( " Not ▁ Skew ▁ Symmetric ▁ Matrix " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int n ) { int ans = 0 , temp = 0 , num ; for ( int i = 1 ; i <= n && temp < n ; i ++ ) { temp = i - 1 ; num = 1 ; while ( temp < n ) { if ( temp + i <= n ) ans += ( i * num ) ; else ans += ( ( n - temp ) * num ) ; temp += i ; num ++ ; } } return ans ; } public static void Main ( ) { int N = 2 ; Console . WriteLine ( findSum ( N ) ) ; } }

Accumulator variables: ans, i, num, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOps ( int [ , ] A , int [ , ] B , int m , int n ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) A [ i , j ] -= B [ i , j ] ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 1 ; j < m ; j ++ ) if ( A [ i , j ] - A [ i , 0 ] - A [ 0 , j ] + A [ 0 , 0 ] != 0 ) return - 1 ; int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) result += Math . Abs ( A [ i , 0 ] ) ; for ( int j = 0 ; j < m ; j ++ ) result += Math . Abs ( A [ 0 , j ] - A [ 0 , 0 ] ) ; return ( result ) ; } public static void Main ( ) { int [ , ] A = { { 1 , 1 , 1 } , { 1 , 1 , 1 } , { 1 , 1 , 1 } } ; int [ , ] B = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; Console . Write ( countOps ( A , B , 3 , 3 ) ) ; } }

Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int key ; public List < Node > child ; } ; static Node newNode ( int value ) { Node nNode = new Node ( ) ; nNode . key = value ; nNode . child = new List < Node > ( ) ; return nNode ; } static int ind ; static Node BuildKaryTree ( int [ ] A , int n , int k , int h ) { if ( n <= 0 ) return null ; Node nNode = newNode ( A [ ind ] ) ; if ( nNode == null ) { Console . WriteLine ( " Memory ▁ error " ) ; return null ; } for ( int i = 0 ; i < k ; i ++ ) { if ( ind < n - 1 && h > 1 ) { ind ++ ; nNode . child . Add ( BuildKaryTree ( A , n , k , h - 1 ) ) ; } else { nNode . child . Add ( null ) ; } } return nNode ; } static Node BuildKaryTree_1 ( int [ ] A , int n , int k , int iN ) { int height = ( int ) Math . Ceiling ( Math . Log ( ( double ) n * ( k - 1 ) + 1 ) / Math . Log ( ( double ) k ) ) ; ind = iN ; return BuildKaryTree ( A , n , k , height ) ; } static void postord ( Node root , int k ) { if ( root == null ) return ; for ( int i = 0 ; i < k ; i ++ ) postord ( root . child [ i ] , k ) ; Console . Write ( root . key + " ▁ " ) ; } public static void Main ( String [ ] args ) { int ind = 0 ; int k = 3 , n = 10 ; int [ ] preorder = { 1 , 2 , 5 , 6 , 7 , 3 , 8 , 9 , 10 , 4 } ; Node root = BuildKaryTree_1 ( preorder , n , k , ind ) ; Console . WriteLine ( " Postorder ▁ traversal ▁ of ▁ " + " constructed ▁ full ▁ k - ary ▁ tree ▁ is : ▁ " ) ; postord ( root , k ) ; Console . WriteLine ( ) ; } }

Index/key variables: i, ind
Accumulator variables: i, ind
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void printCoils ( int n ) { int m = 8 * n * n ; int [ ] coil1 = new int [ m ] ; coil1 [ 0 ] = 8 * n * n + 2 * n ; int curr = coil1 [ 0 ] ; int nflg = 1 , step = 2 ; int index = 1 ; while ( index < m ) { for ( int i = 0 ; i < step ; i ++ ) { curr = coil1 [ index ++ ] = ( curr - 4 * n * nflg ) ; if ( index >= m ) break ; } if ( index >= m ) break ; for ( int i = 0 ; i < step ; i ++ ) { curr = coil1 [ index ++ ] = curr + nflg ; if ( index >= m ) break ; } nflg = nflg * ( - 1 ) ; step += 2 ; } int [ ] coil2 = new int [ m ] ; for ( int i = 0 ; i < 8 * n * n ; i ++ ) coil2 [ i ] = 16 * n * n + 1 - coil1 [ i ] ; Console . Write ( " Coil ▁ 1 ▁ : ▁ " ) ; for ( int i = 0 ; i < 8 * n * n ; i ++ ) Console . Write ( coil1 [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE Coil ▁ 2 ▁ : ▁ " ) ; for ( int i = 0 ; i < 8 * n * n ; i ++ ) Console . Write ( coil2 [ i ] + " ▁ " ) ; } public static void Main ( ) { int n = 1 ; printCoils ( n ) ; } }

Index/key variables: i, m
Accumulator variables: i, index, step
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findSum ( int n ) { int [ , ] arr = new int [ n , n ] ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) arr [ i , j ] = Math . Abs ( i - j ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) sum += arr [ i , j ] ; return sum ; } static public void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( findSum ( n ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += i * ( n - i ) ; return 2 * sum ; } static public void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( findSum ( n ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findSum ( int n ) { n -- ; int sum = 0 ; sum += ( n * ( n + 1 ) ) / 2 ; sum += ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6 ; return sum ; } static public void Main ( String [ ] args ) { int n = 3 ; Console . WriteLine ( findSum ( n ) ) ; } }

Accumulator variables: n, sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int spiralDiaSum ( int n ) { if ( n == 1 ) return 1 ; return ( 4 * n * n - 6 * n + 6 + spiralDiaSum ( n - 2 ) ) ; } public static void Main ( String [ ] args ) { int n = 7 ; Console . Write ( spiralDiaSum ( n ) ) ; } }

Class/struct names: GFG
C# program:
public class GFG { public const int R = 3 ; public const int C = 5 ; public static int numofneighbour ( int [ ] [ ] mat , int i , int j ) { int count = 0 ; if ( i > 0 && mat [ i - 1 ] [ j ] == 1 ) { count ++ ; } if ( j > 0 && mat [ i ] [ j - 1 ] == 1 ) { count ++ ; } if ( i < R - 1 && mat [ i + 1 ] [ j ] == 1 ) { count ++ ; } if ( j < C - 1 && mat [ i ] [ j + 1 ] == 1 ) { count ++ ; } return count ; } public static int findperimeter ( int [ ] [ ] mat ) { int perimeter = 0 ; for ( int i = 0 ; i < R ; i ++ ) { for ( int j = 0 ; j < C ; j ++ ) { if ( mat [ i ] [ j ] == 1 ) { perimeter += ( 4 - numofneighbour ( mat , i , j ) ) ; } } } return perimeter ; } public static void Main ( string [ ] args ) { int [ ] [ ] mat = new int [ ] [ ] { new int [ ] { 0 , 1 , 0 , 0 , 0 } , new int [ ] { 1 , 1 , 1 , 0 , 0 } , new int [ ] { 1 , 0 , 0 , 0 , 0 } } ; Console . WriteLine ( findperimeter ( mat ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, perimeter
Iterator variables: i, j
Class/struct names: GFG