#include <cstdlib>
#include <iostream>
#include <time.h> using namespace std; void repeat(int _count,char *st)
{
for(int i=0;i<_count;i++)
{
cout<<st<<endl;
}
} void count(char *st)
{
int aeiou[5]={0};
for(int i=0;st!='\0';i++)
{
switch(st)
{
case 'a':
case 'A':
aeiou[0]++;
break;
case 'e':
case 'E':
aeiou[1]++;
break;
case 'i':
case 'I':
aeiou[2]++;
break;
case 'o':
case 'O':
aeiou[3]++;
break;
case 'u':
case 'U':
aeiou[4]++;
break;
}
}
cout<<"a:"<<aeiou[0]<<endl;
cout<<"e:"<<aeiou[1]<<endl;
cout<<"i:"<<aeiou[2]<<endl;
cout<<"o:"<<aeiou[3]<<endl;
cout<<"u:"<<aeiou[4]<<endl;
} int main(void)
{
int _count;
char st[128]={0};
cout<<"請輸入欲列印的行數:";
cin>>_count;
cout<<"請輸入欲列印的字串:";
cin>>st;
repeat(_count,st);
count(st);
return(0);
} ...
|