solution.cpp 517 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
    int cnt = 0, flag = 0; //计数
    string s;
    for (int i = 10000; i <= 99999; i++)
    {
        flag = 0;
        stringstream ss;
        ss << i;
        ss >> s;
        for (int j = 0; j < s.length(); j++)
        {
            if (s[j] == '4')
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
            cnt++;
    }
    cout << cnt;
    return 0;
}