1506:数圈圈
Description
幼儿园的小朋友对数字不是很感兴趣,他们更感兴趣的是形状,现在给你一个数字,小朋友都会数出其中一共有多少圆圈圈。
Input
一个数字n长度不超过19位。
Output
输出其中的圈圈数总数。
Sample Input
14589
20869
12357
Sample Output
3
5
0
#include<iostream>
using namespace std;
int main()
{
long long int n,a,b;
while(cin>>n)
{
int count=0;
while(n!=0)
{
b=n;
a=b%10;
if(a==0||a==6||a==9)
count=count+1;
if(a==8)
count=count+2;
n=n/10;
}
cout<<count<<endl;
}
return 0;
}
再给出用string重写的方法就,解决了输入多个0不能判断的问题