游客 Signup | Login
中文 | En

1985 - P272 12

Textbook P272 12

Input

a line

Output

the nunber of lowercase letters.

Examples

Input

OK, good!

Output

4

Solution C

#include<stdio.h>
#include<string.h>

int main(int argc,char* argv[])
{
	char src[1000]={0};
	int len,i,count=0;
	gets(src);
	len = strlen(src);
	for(i=0;i<len;i++)
	{
		if(src[i]>='a'&&src[i]<='z')
			count++;
	}
	printf("%d\n",count);
	
	return 0;
} 

Solution C++

#include<iostream>
#include<string>

using namespace std;

void LowerCount(string,int&);
int main()
{
	int count;
	string a;
	getline(cin,a);
	while (cin)
	{
		LowerCount(a, count);
		cout << count << endl;
		getline(cin, a);
	}
	return 0;
}

void LowerCount(string a, int&y)
{
	y = 0;
	int i=0;
	int x;
	x = a.length();
	string b;
	
	while (i < x)
	{
		b = a.substr(i, 1);
		if (b <= "z"&&b >= "a")
			y++;
		i++;
	}
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题