作者vincent79715 (轩~)
看板NTUBIME101HW
标题[C++] 97上期末考-算母音
时间Thu Jan 15 18:21:21 2009
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inFile("XXX.txt");
char ch=inFile.get();
int s[5]={0};
while(!inFile.eof())
{
if(ch=='A'||ch=='a')
s[0]++;
if(ch=='E'||ch=='e')
s[1]++;
if(ch=='I'||ch=='i')
s[2]++;
if(ch=='O'||ch=='o')
s[3]++;
if(ch=='U'||ch=='u')
s[4]++;
ch=inFile.get();
}
cout<<"母音a有:"<<s[0]<<endl;
cout<<"母音e有:"<<s[1]<<endl;
cout<<"母音i有:"<<s[2]<<endl;
cout<<"母音o有:"<<s[3]<<endl;
cout<<"母音u有:"<<s[4]<<endl;
inFile.close();
system("pause");
return 0;
}
-------------------------------------
虽然已经考完了 当做造福学弟妹吧!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.241.88
※ 编辑: vincent79715 来自: 140.112.241.88 (01/15 18:22)
1F:推 kent2368:造福我我再用依次这样 01/15 18:33
※ 编辑: vincent79715 来自: 140.112.241.88 (01/15 18:54)
※ 编辑: vincent79715 来自: 140.112.241.88 (01/15 18:55)
2F:→ ck940560:我检查过整篇文章 没有大写母音@@ 01/15 23:27
3F:推 jasonfghx:thanks 01/14 13:25