#include <stdio.h>
#include <stdlib.h>
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
bool visited[401];
char map[25][25];
int count;
//int temp;
int newcount;
int DFS(int i,int j,char a[][25],int M,int N)
{
// printf("count:%d",count);
//system("pause");
if(i==M-1&&j == N-1)return newcount = count;
else{
int temp;
printf("count:%d",count);
system("pause");
visited[i*N+j] = true;
for(int k = 0; k < 4; k++)
if(i+dir[k][0]>=0&&i+dir[k][0]<M&&j+dir[k][1]>=0&&j+dir[k][1]<N)
if(map[i+dir[k][0]][j+dir[k][1]]=='#')
count++;
temp = count;
for(int k = 0; k < 4; k++)
if(i+dir[k][0]>=0&&i+dir[k][0]<M&&j+dir[k][1]>=0&&j+dir[k][1]<N)
if(map[i+dir[k][0]][j+dir[k][1]]=='*')
{
if(!visited[(i+dir[k][0])*N+j+dir[k][1]])DFS(i+dir[k][0],j+dir[k][1],a,M,N);
visited[(i+dir[k][0])*N+j+dir[k][1]] = false;
count = temp;
}
return count;
}
}
int main()
{
int M,N;
while(~scanf("%d%d",&M,&N))
{
getchar();
for(int i = 0; i < 401; i++)
visited[i] = false;
count = 0;
if(M==0&&N==0)break;
for(int i = 0; i < M; i++)
gets(map[i]);
//DFS(0,0,map,M,N);
printf("%d\n",DFS(0,0,map,M,N));
}
system("pause");
return 0;
}
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <string>
#include <algorithm>
using namespace std;
char code[1010];
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
getchar();
gets(code);
int i = 0;
int a = 0,b = 0;
while(code[i]!='\0')
{
switch(code[i])
{
case '{':
printf("\n");
for(int k = 0; k < b*5; k++)
printf(" ");
printf("{\n");
b++;
for(int k = 0; k < b*5; k++)
printf(" ");
break;
case '}':
b--;
for(int k = 0; k < b*5; k++)
printf(" ");
printf("}");
if(code[i+1]!='\0')
{
printf("\n");
for(int k = 0; k < b*5; k++)
printf(" ");
}
else printf("\n");
break;
case '(':
a++;
printf("(");
break;
case ')':
a--;
printf(")");
break;
case ';':
if(a!=0)printf(";");
else{
printf(";\n");
if(code[i+1]!='}')
for(int k = 0; k < b*5; k++)
printf(" ");
}
break;
default:
printf("%c",code[i]);
}
i++;
}
if(n)printf("\n");
}
//system("pause");
return 0;
}