其他字符算一个,贴下我的 #include <iostream> (30316)#include <vector> #include <string> (30191)#include <sstream> using namespace std; void getStringCount(string content){ bool isCharUpper = false; int count = 0; for(int i = 0;i < content.length();++i){ // if(!isalpha(content[i])) return;///非字母跳出 if(islower(content[i]) && isCharUpper){ if(i + 1 < content.length() && islower(content[i + 1])){ isCharUpper = false; count += 1;///按下caps }else{ count += 1;///按下shift } }else if(isupper(content[i]) && !isCharUpper){ if(i + 1 < content.length() && isupper(content[i + 1])){ isCharUpper = true; count += 1;///按下caps }else{ count += 1;///按下shift } } count += 1; } cout << count << endl; } int main() { int n; cin>>n; for(int i = 0;i < n;++i){ string str; cin>>str; getStringCount(str); } }
点赞 评论

相关推荐

湫湫湫不会java:先投着吧,大概率找不到实习,没实习的时候再加个项目,然后把个人评价和荣誉奖项删了,赶紧成为八股战神吧,没实习没学历,秋招机会估计不多,把握机会。或者说秋招时间去冲实习,春招冲offer,但是压力会比较大
点赞 评论 收藏
分享
06-02 15:53
阳光学院 Java
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务