通知
すべてクリア
Topic starter
2003年7月28日 2:49 PM
こんなもんでいいんですかね?
STLのアルゴリズムとかでできそうな気がするんだけど、力が無い。
満足感が得られないんで、STL得意な人の添削希望。
std::string ToLowerString( const std::string& str )
{
std::string lowStr;
std::string::const_iterator p = str.begin();
for( ;p < str.end(); ++p ){
lowStr += tolower( *p ) ;
}
return lowStr;
}
2003年7月28日 3:10 PM
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
std::string ToLowerString( const std::string& str ) {
std::string lowStr(str.size(), '\0');
std::transform(str.begin(), str.end(), lowStr.begin(), &tolower);
return lowStr;
}
int main() {
std::cout << ToLowerString(To Be Small Letters) << std::endl;
return 0;
}
Topic starter
2003年7月28日 3:46 PM
replace_copy_ifとか筋違いので一生懸命考えてて、ウツ。
いつもすいませんです。
ありがとうござい。