时间限制:1Sec内存限制:128MB通过:47提交:80
题目描述
Twinkle, twinkle, little star! How I wonder what you are, Up above the world so high, Like a diamond in the sky. When the blazing sun is gone, When he nothing shines upon, Then you show your little light, Twinkle, twinkle all the night. The dark blue sky you keep, And often thro’ my curtains peep, For you never shut your eye, Till the sun is in the sky. 'Tis your bright and tiny spark, Lights the traveler in the dark, Though I know not what you are, Twinkle, twinkle, little star! “How beautiful!” GG and MM said to each other! “But can you count all stars in the sky?” GG asked. MM counts and counts and fells asleep…
输入
There are multiple test cases. The first line has two integers N and M (1<=N,M<=1000) indicates that the visible sky are discretized with N lines and M columns. Then follows N lines and each line has M characters. The “*” character indicates the star in the sky and the “.” character indicates the sky. You should process all cases until M=0 and N=0.
输出
For each output case, you should output one integer indicating the counts of stars in the sky.
样例输入
1 1
*
2 2
.
.
0 0
样例输出
1
2
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
while(~scanf("%d %d",&a,&b))
{
if(a==0&&b==0)
break;
char c[a*b];
for(int i=0;i<a*b;i++)
{
cin>>c[i];
}
int sum=0;
for(int i=0;i<a*b;i++)
{
if(c[i]=='*')
sum++;
}
cout<<sum<<endl;
}
}