1 개요[ | ]
- C++ 문자열 대문자로 변환
- C++ strtoupper() 구현
- C++ uppercase() 구현
C++
CPU
0.4s
MEM
47M
0.7s
Copy
#include <iostream>
using namespace std;
string strtoupper(string str) {
for(auto &c: str) c = toupper(c);
return str;
}
int main() {
cout << strtoupper("Hello World!") << endl; // HELLO WORLD!
}
HELLO WORLD!
C++
Copy
#include <iostream>
#include <algorithm>
using namespace std;
string strtoupper(const string str) {
string ret = str;
transform(ret.begin(), ret.end(),ret.begin(), ::toupper);
return ret;
}
int main() {
cout << strtoupper("Hello World!") << endl; // HELLO WORLD!
}
Loading
2 같이 보기[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.