1"use strict";(self.webpackChunkdocsv_2=self.webpackChunkdocsv_2||[]).push([[1287],{8902:(n,e,i)=>{i.r(e),i.d(e,{assets:()=>d,contentTitle:()=>c,default:()=>m,frontMatter:()=>l,metadata:()=>r,toc:()=>u});const r=JSON.parse('{"id":"algorithms/8queens","title":"8 Queens in C","description":"8 Queens in C","source":"@site/docs/three/algorithms/8queens.mdx","sourceDirName":"algorithms","slug":"/algorithms/8queens","permalink":"/docs/three/algorithms/8queens","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":14,"frontMatter":{"sidebar_position":14,"description":"8 Queens in C"},"sidebar":"tutorialSidebar","previous":{"title":"Floyd Warshall Algorithm","permalink":"/docs/three/algorithms/warshall"},"next":{"title":"String Matching","permalink":"/docs/three/algorithms/stringMatch"}}');var t=i(4848),o=i(8453),s=i(1432);const a='#include <stdio.h>\n#include <stdlib.h>\n#include <math.h>\n\nint board[8];\n\nint place(int row, int column)\n{\n for (int i = 0; i < row; i++)\n {\n if (board[i] == column || abs(board[i] - column) == abs(i - row))\n {\n return 0;\n }\n }\n return 1; // No conflict\n}\n\nvoid print_board(int n)\n{\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < n; j++)\n {\n if (board[i] == j)\n {\n printf("Q ");\n }\n else\n {\n printf(". ");\n }\n }\n printf("\\n");\n }\n printf("\\n");\n}\n\nvoid Queen(int row, int n)\n{\n if (row == n)\n {\n print_board(n);\n }\n else\n {\n for (int column = 0; column < n; column++)\n {\n if (place(row, column))\n {\n board[row] = column;\n Queen(row + 1, n);\n }\n }\n }\n}\n\nint main()\n{\n int n = 8;\n Queen(0, n);\n return 0;\n}\n',l={sidebar_position:14,description:"8 Queens in C"},c="8 Queens in C",d={},u=[{value:"CODE",id:"code",level:2}];function h(n){const e={h1:"h1",h2:"h2",header:"header",...(0,o.R)(),...n.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e.header,{children:(0,t.jsx)(e.h1,{id:"8-queens-in-c",children:"8 Queens in C"})}),"\n",(0,t.jsx)(e.h2,{id:"code",children:"CODE"}),"\n",(0,t.jsx)(s.A,{language:"c",children:a})]})}function m(n={}){const{wrapper:e}={...(0,o.R)(),...n.components};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(h,{...n})}):h(n)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.