题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
#include <iostream> #include <string> using namespace std; int main() { int num; int res = 0; string tem_s; while (cin >> num) { // 注意 while 处理多个 case for(int i = 1;i<=num;i++){ if(i%7==0){ res++; //cout<<i<<' '; continue; } tem_s = to_string(i); for(auto x:tem_s){ if(x=='7'){ res++; //cout<<tem_s<<' '; break; } } } cout<<res; } } // 64 位输出请用 printf("%lld")