标签:col 图片 type style line ++ ret img bsp
水题。
#include<iostream> #include<cctype> using namespace std; string str; int main() { getline(cin,str); int sum = 0,r ,cnt0 = 0,cnt1 = 0; for(int i = 0; i < str.size(); ++i) { if(isalpha(str[i])) { str[i] = tolower(str[i]); sum += str[i]-‘a‘+1; } } while(sum > 0){//在十进制数转二进制数过程中,统计0,1的个数 r = sum%2; if(r == 0) cnt0++; else cnt1++; sum /= 2; } printf("%d %d",cnt0,cnt1); return 0; }
这几天有点飘,是不是戒断期来了。。。
标签:col 图片 type style line ++ ret img bsp
原文地址:https://www.cnblogs.com/keep23456/p/12348610.html