长安大学第二届ACM校赛题解 A Count Circles

Count Circles

发布时间: 2017年4月19日 15:09 最后更新: 2017年4月19日 16:04 时间限制: 1000ms 内存限制: 128M

描述
Stupid Aguin feels confused while reading. The book shows following equations:
6=9 , 8=1010 , 144=75 , 690=801
Stupid Aguin doesn’t know why and he asks RoyYuan for help. RoyYuan tells Aguin that he only needs to count circles in each number. Notice that 0 , 6 and 9 have one circle, and 8 has two circles. For example, both 690 and 801 have 3 circles, so 690 = 801.

However, Aguin is too stupid to count circles in each number, please help him.

输入
The first line contains an integer number T, the number of test cases.

i-th of each next T lines contains an integer number x(0≤x≤109).

输出
For each test case print a number, the number of circles in x.

样例输入1 复制
8
6
9
8
1010
144
75
690
801

样例输出1
1
1
2
2
0
0
3
3

题目思路:字符串统计一下就好

#include<iostream> 
#include<string>

using namespace std;

int main() {
    string num;
    int cases__;
    cin >> cases__;
    while (cases__--) {
        cin >> num;
        int R__ = 0;
        for (string::iterator i = num.begin(); i != num.end(); i++) {
            if (*i == '0' || *i == '6' || *i == '9')
                R__++;
            if (*i == '8')
                R__ += 2;
        }
        cout << R__ << endl;
    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值