import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m = "";
while((m=br.readLine())!=null){
String[]str=m.split(" ");
int x=Integer.parseInt(str[0]);
int y=Integer.parseInt(str[1]);
if(x==0 &&y==0)
break;
char[][]arr=new char[x+2][y+2];
for(int i=0;i<x+2;i++){
arr[i][0]='.';
}
for(int i=0;i<y+2;i++){
arr[0][i]='.';
}
for(int i=0;i<x+2;i++){
arr[i][y+1]='.';
}
for(int i=0;i<y+2;i++){
arr[x+1][i]='.';
}
for(int i=1;i<x+1;i++){
String temp=br.readLine();
for(int j=1;j<y+1;j++){
arr[i][j]=temp.charAt(j-1);
}
}
sb.append(stars(arr)).append("\n");
}
System.out.print(sb);
}
static int stars(char[][]arr){
int counter=0;
for(int i=1;i<arr.length-1;i++){
for(int j=1;j<arr[0].length-1;j++){
if(arr[i][j]=='*'){
if(arr[i-1][j-1]=='*'){
continue;
}
if(arr[i-1][j]=='*'){
continue;
}
if(arr[i-1][j+1]=='*'){
continue;
}
if(arr[i][j-1]=='*'){
continue;
}
if(arr[i][j+1]=='*'){
continue;
}
if(arr[i+1][j-1]=='*'){
continue;
}
if(arr[i+1][j]=='*'){
continue;
}
if(arr[i+1][j+1]=='*'){
continue;
}
counter++;
}
}
}
return counter;
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m = "";
while((m=br.readLine())!=null){
String[]str=m.split(" ");
int x=Integer.parseInt(str[0]);
int y=Integer.parseInt(str[1]);
if(x==0 &&y==0)
break;
char[][]arr=new char[x+2][y+2];
for(int i=0;i<x+2;i++){
arr[i][0]='.';
}
for(int i=0;i<y+2;i++){
arr[0][i]='.';
}
for(int i=0;i<x+2;i++){
arr[i][y+1]='.';
}
for(int i=0;i<y+2;i++){
arr[x+1][i]='.';
}
for(int i=1;i<x+1;i++){
String temp=br.readLine();
for(int j=1;j<y+1;j++){
arr[i][j]=temp.charAt(j-1);
}
}
sb.append(stars(arr)).append("\n");
}
System.out.print(sb);
}
static int stars(char[][]arr){
int counter=0;
for(int i=1;i<arr.length-1;i++){
for(int j=1;j<arr[0].length-1;j++){
if(arr[i][j]=='*'){
if(arr[i-1][j-1]=='*'){
continue;
}
if(arr[i-1][j]=='*'){
continue;
}
if(arr[i-1][j+1]=='*'){
continue;
}
if(arr[i][j-1]=='*'){
continue;
}
if(arr[i][j+1]=='*'){
continue;
}
if(arr[i+1][j-1]=='*'){
continue;
}
if(arr[i+1][j]=='*'){
continue;
}
if(arr[i+1][j+1]=='*'){
continue;
}
counter++;
}
}
}
return counter;
}
}
No comments:
Post a Comment