程序统计数字4或7的个数,如果它们的个数能被7和4组成的数整除,则输出YES...
bool test(int z)
{
while (z)
{
if (z % 10 != 4 || z % 10 != 7)
return false;
z /= 10;
}
return true;
}
int main()
{
long long x;
cin >> x;
int k = 0;
while (x)
{
if (x % 10 == 4 || x % 10 == 7)
++k;
x /= 10;
}
if (test(k) == true)
cout << "YES";
else
cout << "NO";
return 0;
}
立马吸引眼球
此条件始终为真。
看看这段代码: