C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Created by Ruchika Sehgal
#include <stdio.h>
//function checking and returning the best value
/*void bestpos(int n, char a[n][n], int *r, int *c){
int rnew=0, cnew=0;int flag=0;int rbest=0, cbest=0, bestflag;
int i=0,j=0;
bestflag=flag;
while(1){
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if((i==rnew)||(j==cnew)||((rnew+cnew)==(i+j))||(rnew-cnew)==(i-j))
{
if(a[i][j]=='Q')
{
continue;
}
else{
flag++;
}
}
}
if (flag>bestflag){
bestflag=flag;
rbest=rnew;
cbest=cnew;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run