类的学习
#include <iostream.h>
#include "String.h"
int main()
{
int aCnt =0, eCnt = 0, iCnt=0,uCnt=0,
theCnt=0, itCnt=0,wdCnt=0,notVowel=0;
//为了使用operator==(const char*)
//我们并不定义The("the"),TI("It")
String buf,the("the"),it("it");
//调用operator>>(istream&,String&)
while( cin >> buf ){
++wdCnt;
//调用operator<<(ostream&,const String&)
cout<<buf<< ' ';
if ( wdCnt%12==0 )
cout <<endl;
//调用String::operator==(const String&) and
// String::operator==(const char*);
if ( buf ==the || buf == "The" )
++theCnt;
else
if (buf == the || buf == "The" )
++itCnt;
//调用String::size()
for( int ix =0; ix < buf.size(); ++ix )
{
//调用String::operator[](int)
switch( buf[ix] )
{
case 'a': case 'A':
++aCnt;
break;
case 'e': case 'E':
++eCnt;
break;
case 'i': case 'I':
++iCnt;
break;
case 'o': case 'O':
++oCnt;
break;
case 'u': case 'U';
++uCnt;
break;
default:
++notVowel;
break;
}
}
}
//调用operator<<( ostream&, const String& )
cout << "\n\n"
<<"Words read: " << wdCnt <<"\n\n"
<<"the/The: " <<theCnt <<'\n'
<<"it/It: " <<itCnt <<"\n\n"
<<"non-vowels read: " << notVowel << "\n\n"
<<"a: "<<aCnt<<'\n'
<<"e: "<<eCnt<<'\n'
<<"i: "<<iCnt<<'\n'
<<"o: "<<oCnt<<'\n'
<<"u: "<<uCnt<<endl;
}
#include "String.h"
int main()
{
int aCnt =0, eCnt = 0, iCnt=0,uCnt=0,
theCnt=0, itCnt=0,wdCnt=0,notVowel=0;
//为了使用operator==(const char*)
//我们并不定义The("the"),TI("It")
String buf,the("the"),it("it");
//调用operator>>(istream&,String&)
while( cin >> buf ){
++wdCnt;
//调用operator<<(ostream&,const String&)
cout<<buf<< ' ';
if ( wdCnt%12==0 )
cout <<endl;
//调用String::operator==(const String&) and
// String::operator==(const char*);
if ( buf ==the || buf == "The" )
++theCnt;
else
if (buf == the || buf == "The" )
++itCnt;
//调用String::size()
for( int ix =0; ix < buf.size(); ++ix )
{
//调用String::operator[](int)
switch( buf[ix] )
{
case 'a': case 'A':
++aCnt;
break;
case 'e': case 'E':
++eCnt;
break;
case 'i': case 'I':
++iCnt;
break;
case 'o': case 'O':
++oCnt;
break;
case 'u': case 'U';
++uCnt;
break;
default:
++notVowel;
break;
}
}
}
//调用operator<<( ostream&, const String& )
cout << "\n\n"
<<"Words read: " << wdCnt <<"\n\n"
<<"the/The: " <<theCnt <<'\n'
<<"it/It: " <<itCnt <<"\n\n"
<<"non-vowels read: " << notVowel << "\n\n"
<<"a: "<<aCnt<<'\n'
<<"e: "<<eCnt<<'\n'
<<"i: "<<iCnt<<'\n'
<<"o: "<<oCnt<<'\n'
<<"u: "<<uCnt<<endl;
}
...全文
相关推荐
java类的学习
通过实践和学习资源,如提供的视频教程,你将逐渐加深对Java类的掌握,从而进一步提升你的编程技能。
Java中类的继承学习小结
下面是对"Java中类的继承学习小结"的详细讲解。首先,类的继承使用关键字`extends`来实现。
类图实例,关于类图学习心得、类图怎么画、visio作图
总结来说,类图是理解系统结构的关键,它通过图形化的方式展现了类的属性、操作以及类与类之间的关系。使用Visio这样的工具可以方便快捷地绘制类图,有助于学习和交流。
VB类模块学习
### VB类模块学习知识点#### 一、类的基本定义与应用概述1.
Java 对象和类的学习例子
在Java编程语言中,对象和类是核心概念,它们构成了面向对象编程的基础。在这个学习例子中,我们将深入探讨这两者以及它们如何相互作用。首先,我们来理解什么是类。类可以看作是创建对象的蓝图或者模板。


新手乐园
