Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cctype>
- using namespace std;
- int main() {
- string s;
- cin >> s;
- bool is_snake = false;
- int len = s.length();
- for(int i = 0; i < len; ++i) {
- if(s.at(i) == '_') {
- is_snake = true;
- break;
- }
- }
- string output = "";
- if(is_snake) {
- for(int i = 0; i < len; ++i) {
- if(s.at(i) == '_') {
- i = i + 1;
- if(i < len) output += toupper(s.at(i));
- } else output += s.at(i);
- }
- } else {
- for(int i = 0; i < len; ++i) {
- if(isupper(s.at(i))) {
- output += '_';
- output += tolower(s.at(i));
- } else output += s.at(i);
- }
- }
- cout << output << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement