• 1791 设备编号 A


     

    6.C/c++数字转字符串:

    string str = to_string(i);

    7.查找字符/字符串

    T.find(P,begin) != strting::npos;

    代码:

    #include <iostream>
    using namespace std;
    
    class Solution {
    public:
        int GetCountNum(int start, int end) const
        {
            int count = 0;
            for (int i = start; i <= end; i++) {
                string str = to_string(i);
                int begin = -1;
                if (str.find("18", begin + 1) != string::npos || str.find("4", begin + 1) != string::npos) {
                    count++;
                }
            }
            return count;
        }
        // 待实现函数,在此函数中填入答题代码;
        int GetNormalDeviceNum(int start, int end) const
        {
            int cnt = GetCountNum(start, end);
            int result = 0;
            result = end - start - cnt + 1;
    
            return result;
        }
    };
    
    // 以下为考题输入输出框架,此部分代码不建议改动
    inline int ReadInt()
    {
        int number;
        std::cin >> number;
        return number;
    }
    
    
    int main()
    {
        int start = ReadInt();
        int end = ReadInt();
    
        Solution solu;
        int result = solu.GetNormalDeviceNum(start, end);
        cout << result;
        return 0;
    }
  • 相关阅读:
    linux之参数实用讲解
    Linux脚本中调用SQL,RMAN脚本
    shell for参数
    Linux Shell参数替换
    Python OOP(1)
    Python 不可变对象
    Python set
    Python tuple
    Python list,tuple,dict and set
    Python 可变长度函数参数
  • 原文地址:https://www.cnblogs.com/gcter/p/15884626.html
Copyright © 2020-2023  润新知