西工大数据结构极简解法--016计算二叉树叶子结点数目

题目描述

西工大数据结构极简解法--016计算二叉树叶子结点数目_第1张图片

极简解法

#include
#include
int main()
{
	int cnt=0,num=0;
	char s[10005];
	gets(s);
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='#') cnt++;
		if(s[i]>=65&&s[i]<=90)cnt=0;	
		if(cnt>=2)
		{
			num++;cnt=0;
		}		
	}
	printf("%d",num);
	return 0;	
}  

你可能感兴趣的:(NOJ数据结构,数据结构)