题意:

  给一个字符串,删掉所有的'_',然后将‘_'后的第一个字符改成大写。

代码:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long LL;
 4 
 5 class NamingConvention{
 6 public:
 7     string toCamelCase(string str) {
 8         string res; res.clear();
 9         for (int i=0; i<str.size(); ++i) {
10             if (str[i] == '_') continue;
11             else if (i >= 1 && str[i - 1] == '_') res.push_back(str[i] + 'A' - 'a');
12             else res.push_back(str[i]); 
13         }
14         return res;
15     }
16 };

 

相关文章:

  • 2021-08-30
  • 2021-07-23
  • 2021-12-18
  • 2022-02-26
  • 2021-07-06
  • 2021-09-30
  • 2021-06-06
  • 2021-10-23
猜你喜欢
  • 2021-10-06
  • 2021-04-14
  • 2022-02-20
  • 2022-01-22
  • 2021-06-06
  • 2021-06-26
相关资源
相似解决方案