题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <stdio.h> int concerning7(int num) { if (num%7==0) return 1; else { int k=num; while(k>0) { if (k%10==7) return 1; else k /= 10; } } return 0; } int main() { int n, i,cnt=0; scanf("%d\n", &n); for (i=1; i<=n; i++) { cnt += concerning7(i); } printf("%d\n", cnt); return 0; }