C语言作业,供初学者参考
#include <iostream.h>
void main()
{
char c;
int count=0;
cout<<"enter your char:"<<endl;
while((c=cin.get())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
count++;
}
cout<<count<<endl;
}
#include <iostream.h>
int mm(char x[]);
void main()
{
char c[100];
cin.getline(c,100);
cout<<mm(c)<<endl;
}
int mm(char x[])
{
int count=0;
for(int i=0;i<100;i++)
{
if(x[i]>='a'&&x[i]<='z'||x[i]>='A'&&x[i]<='Z')
count++;
}
return count;
}
本文地址:http://com.8s8s.com/it/it24510.htm