记录输入的字母个数(C code)

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 raiden56 的 blog

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;
}

本文关键:记录输入的字母个数(C code)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top