1057 数零壹 (20分)
难点:无
重点:使用getline获取一行数据,因为可能包含空格。
#include<iostream>
#include<string>
#include<math.h>
using namespace std;int main()
{string s;getline(cin,s);int sum = 0;for (int i = 0; i < s.size(); i++){if (s[i] >= 'a' && s[i] <= 'z')sum += s[i] - 'a' + 1;if (s[i] >= 'A' && s[i] <= 'Z')sum += s[i] - 'A' + 1;}int a = 0, b = 0;//a,b分别表示0,1while (sum){if (sum % 2 == 0)a++;elseb++;sum = sum / 2;}cout << a << " " << b;return 0;
}