哪位强人做下c++函数write a void function

来源:百度知道 编辑:UC知道 时间:2024/05/12 07:40:19
write a void function,LowerCount,that reads a line from cin,and return an int(count)containing the number of lowercase letters in the line.In Appendix C you will find the description of function islower,which returns true if its char parameter is a lowercase character.Document the data flow of the parameters with appropriate comments.
#include<iostream>
#include<string>
using namespace std;
void LowerCount(string,char,int);

int main()
{
string str;
char lch;
int count;
LowerCount(str,lch,count);

}
void LowerCount(string str,char lch,int count)
{
cin>>str;
cout<<str<<endl;
cin.get(str);
while(str='a'||'b'||'c'||'d'||'e'||'f'||'g'||'h'||'i'||'j'||'k'||'l'||'m'||'n'||'o'||'p'||'q'||'r'||'s'||'t'||&

你这代码写的挺无辜的,人家都告诉你用islower了,看你那一大串||

#include <iostream>
#include <cctype>
#include <string>
using namespace std;

int foo(void)
{
string input;
getline(cin, input);
int cl = 0;

for(size_t i = 0; i != input.size(); ++i)
if(islower(input[i]))
++cl;
return cl;
}

int main()
{
cout << "lower ch: " << foo() << endl;
}

that is so easy to every body that do it without thinking.why do not you try your best to do???