题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <stdio.h> int main() { int n; while (scanf("%d", &n) != EOF) { int count = 0; for(int i = 7; i <= n; i++) { if(i % 7 == 0) { count++; // printf("数字 %d 是 7 的倍数,计数增加。\n", i); } else if( i > 10) { int m = i; while(m > 0) { if(m % 10 == 7){ // printf("数字 %d 包含数字 7,计数增加。\n", i); count++; break; } m /= 10; } } } printf("%d\n", count); } return 0; }