← 查看本卷题目GESP C++ 3级2024年12月单选题 第12题 · 2 分想要计算从数字n到数字m之间(包含n和m)有多少个数字d出现,下列程序哪个能够实现( )。 填写答案Acpp int n,m,res,d; cin >> n >> m>>d; for(int i = n+1; i <= m; i++){ int temp = i; while(temp){ if(temp % 10 == d) res++; temp /= 10; } } cout << res << endl; return 0; Bcpp int n,m,res,d; cin >> n >> m>>d; for(int i = n; i <= m; i++){ int temp = i; while(temp){ if(temp % 10 = d) res++; temp /= 10; } } cout << res << endl; return 0; Ccpp int n,m,res=0,d; cin >> n >> m>>d; for(int i = n; i <= m; i++){ int temp = i; while(temp){ if(temp % 10 == d) res++; temp /= 10; } } cout << res << endl; return 0; Dcpp int n,m,res=0,d; cin >> n >> m>>d; for(int i = n; i <= m; i++){ while(temp){ if(temp % 10 == d) res++; temp /= 10; } } cout << res << endl; return 0; 提交答案详细解析这题不会 ← 上一题 第 282 / 378 题← → 键切题 下一题 →
想要计算从数字n到数字m之间(包含n和m)有多少个数字d出现,下列程序哪个能够实现( )。 填写答案Acpp int n,m,res,d; cin >> n >> m>>d; for(int i = n+1; i <= m; i++){ int temp = i; while(temp){ if(temp % 10 == d) res++; temp /= 10; } } cout << res << endl; return 0; Bcpp int n,m,res,d; cin >> n >> m>>d; for(int i = n; i <= m; i++){ int temp = i; while(temp){ if(temp % 10 = d) res++; temp /= 10; } } cout << res << endl; return 0; Ccpp int n,m,res=0,d; cin >> n >> m>>d; for(int i = n; i <= m; i++){ int temp = i; while(temp){ if(temp % 10 == d) res++; temp /= 10; } } cout << res << endl; return 0; Dcpp int n,m,res=0,d; cin >> n >> m>>d; for(int i = n; i <= m; i++){ while(temp){ if(temp % 10 == d) res++; temp /= 10; } } cout << res << endl; return 0; 提交答案详细解析这题不会