#include <iostream> void caculate(char* str); int main() { caculate(“adiueiiuop12A121ooookkaaljlw2″); return 0; } void caculate(char* str) { using namespace std; int j,a,e,i,o,u; /*a=0;e=0;i=0;o=0;u=0;*/ a=e=i=o=u=0; for (j=0;j<strlen(str)+1;j++) { if(str[j]==’a’||str[j]==’A’) a++; if(str[j]==’e’||str[j]==’E’) e++; if(str[j]==’i’||str[j]==’I’) i++; if(str[j]==’o’||str[j]==’O’) o++; if(str[j]==’u’||str[j]==’U’) u++; } cout<<”a=”<<a<<”times”<<endl; cout<<”e=”<<e<<”times”<<endl; cout<<”i=”<<i<<”times”<<endl; cout<<”o=”<<o<<”times”<<endl; cout<<”u=”<<u<<”times”<<endl; } |
|