时间超限
程序代码:
#include<iostream> #include<string> using namespace std; string p(string s1,string &s2){ for(size_t i=0;i!=s1.size();++i){ switch (s1[i]){ case 'a': case 'A': s2.push_back(s1[i]); ++i; break; case 'o': case 'O': s2.push_back(s1[i]); ++i; break; case 'e': case 'E': s2.push_back(s1[i]); ++i; break; case 'i': case 'I': s2.push_back(s1[i]); ++i; break; case 'u': case 'U': s2.push_back(s1[i]); ++i; break; } } return s2;} int main(){ string s1,s2; cin>>s1; p(s1,s2); cout<<s2<<endl; return 0; }
这是一道输出字符串中元音字母的代码,我在OJ 上做的 判题结果是 时间超限,我想问怎么改进