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