I have done Following code to count X in an array. Here the compliation error which i get.
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
char s [n][n] ;
cin>>n;
char c ;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin >> c ;
if(c=='X')
{
s[i][j]='X';
}
}
}
int count=0;
for(int i=1;i<n-1;i++)
{
for(int j=1;j<n-1;j++)
{
if( s[i][j]=='X' && s[i−1][j−1] =='X' && s[i−1][j+1]=='X'&& s[i+1][j−1] =='X' && s[i+1][j+1] =='X')
count++;
}
}
cout<<count<<endl;
return 0;
}
prog.cpp: In function ‘int main()’: prog.cpp:23:34: error: expected ‘:’ before ‘]’ token { if( s[i][j]=='X' && s[i?1][j?1] =='X' && s[i?1][j+1]=='X'&& s[i+1][j?1] =='X' && s[i+1][j+1] =='X') ^