其他字符算一个,贴下我的 #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); } }
点赞 评论

相关推荐

本科生是不是只能去送外卖了
有气魄的海豚在喝茶:外卖这个版本被保安克制
点赞 评论 收藏
分享
03-24 16:56
已编辑
肇庆学院 后端
一天代码十万三:你看看人家进大厂的简历就知道了,你这个学历得acm+大厂实习+熟悉底层+运气很好 才有可能进某个大厂,因为大部分是直接卡学历的
投递快手等公司10个岗位
点赞 评论 收藏
分享
牛客网
牛客企业服务