//Programma prova esame
#include <stdio.h>
#include <stdlib.h>
#define R 6
#define C 10
int main(int argc,char *argv[])
{
if (argc!=2)
{
printf(“errore”);exit(1);}
FILE *fp;
fp=fopen(argv[1],"r");
char ma[R][C+2];
int i,fl,fl1,fl2,x,y,j;fl=1;
int na[R][C]={{0}};
for (i=0;i<R;i++)
{fscanf(fp,"%s",ma[i]);
}
for (i=0;i<R;i++)
puts(ma[i]);
while (fl==1)
{
printf("inserire coordinate riga e colonna");
scanf ("%d %d",&y,&x);
if (na[y][x]==1)
{
printf("casella gia colpita\n");
}else {na[y][x]=1;
if (ma[y][x]=='V')
{
printf("colpito\n");
ma[y][x]='X';
for (i=y,fl2=0,fl1=0;i<R&&fl1==0&&fl2==0;i++)
{if (ma[i][x]=='V')
fl1=1;
if (ma[i][x]=='o')
fl2=1;}
for (i=y,fl2=0;i>=0&&fl1==0&&fl2==0;i--)
{if (ma[i][x]=='V')
fl1=1;
if (ma[i][x]=='o')
fl2=1;}
for (i=x,fl2=0;i>=0&&fl1==0&&fl2==0;i--)
{if (ma[y][i]=='V')
fl1=1;
if (ma[y][i]=='o')
fl2=1;}
for (i=x,fl2=0;i<C&&fl1==0&&fl2==0;i++)
{if (ma[y][i]=='V')
fl1=1;
if (ma[y][i]=='o')
fl2=1;}
if (fl1==0)
printf("affondata\n");
}
if (ma[y][x]=='o')
{
printf("acqua\n");
}}
for (i=0,fl=0;i<R&&fl==0;i++)
for (j=0;j<C;j++)
if (ma[i][j]=='V')
fl=1;
}
return 0;
}