看板 NTUBIME101HW 關於我們 聯絡資訊
#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)
kent2368:造福我我再用依次這樣 01/15 18:33
※ 編輯: vincent79715 來自: 140.112.241.88 (01/15 18:54) ※ 編輯: vincent79715 來自: 140.112.241.88 (01/15 18:55)
ck940560:我檢查過整篇文章 沒有大寫母音@@ 01/15 23:27
jasonfghx:thanks 01/14 13:25