As is known to all,the ASCII of character 'a' is 97. Now,find out how many character 'a' in a group of given numbers. Please note that the numbers here are given by 32 bits’ integers in the computer.That means,1digit represents 4 characters(one character is represented by 8 bits’ binary digits).
3 97 24929 100
3
队友写的,思路很巧妙。
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,a;
while(~scanf("%d",&n))
{
int sum=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a);
while(a)
{
int b=a%256;
if(b==97)
sum++;
a=a/256;
}
}
printf("%d\n",sum);
}
return 0;
}