c语言
#include <stdio.h> #include <string.h> int main() { char buf[8]; int num = 0; scanf("%d", &num); int skip = 0; for (size_t i = 0; i < num; i++) { sprintf(buf, "%d", i); char* r = strchr(buf, '4'); if(NULL == r) continue; else skip++; } // printf("skip=%d\r\n", skip); printf("%d\r\n", num-skip); }</string.h></stdio.h>