Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  su4.c
Language: C/C++
Code:
#include<stdio.h>
int main()
{
    int n,count=0,i,j,r,ro[351],cl[351];
    char a[351][351];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
            scanf("%c",&a[i][j]);
    }
    
    scanf("%d",&r);
    for(i=1;i<=r;i++)
    {
        scanf("%d%d",&ro[i],&cl[i]);
        if(ro[i]==1)
        {
            if(cl[i]==1 && a[ro[i]+1][cl[i]]=='x' && a[ro[i]][cl[i]+1]=='x')
                count++;
            if(cl[i]==n && a[ro[i]+1][cl[i]]=='x' && a[ro[i]][cl[i]-1]=='x')
                count++;
            else 
            {
            if(a[ro[i]+1][cl[i]]=='x' && a[ro[i]][cl[i]+1]=='x' &&
            a[ro[i]][cl[i]-1]=='x')
                count++;
            }
        }
        if(ro[i]==n)
        {
            if(cl[i]==1 && a[ro[i]-1][cl[i]]=='x' && a[ro[i]][cl[i]+1]=='x')
                count++;
            if(cl[i]==n && a[ro[i]-1][cl[i]]=='x' && a[ro[i]][cl[i]-1]=='x')
                count++;
            else 
            {
            if(a[ro[i]-1][cl[i]]=='x' && a[ro[i]][cl[i]+1]=='x' &&
            a[ro[i]][cl[i]-1]=='x')
                count++;
            }
        }
        else
        {
            if(a[ro[i]-1][cl[i]]=='x' && a[ro[i]+1][cl[i]]=='x' && a[ro[i]][cl[i]+1]=='x' && a[ro[i]][cl[i]-1]=='x')
                count++;
        }
    }
    if(count==0)
        printf("\nYes");
    else
        printf("\nNo");
                
    return 0;
}
          
Comments: