幸运数字 题解
题目在主页,如有出错请指出
include <bits/stdc++.h>
using namespace std;
bool pd(int n)
{
int j = 0, o = 0;
bool f = 0;
while (n != 0)
{
if (f != 0)
{
o += n % 10;
f = 0;
}
else
{
j += n % 10;
f = 1;
}
n /= 10;
}
if (j == o) return 1;
return 0;
}
int main()
{
int a, b;
cin >> a >> b;
int s = 0;
for (int i = a;i <= b;i++)
if (pd(i) != 0) s += 1;
cout << s << endl;
return 0;
}