想要计算从数字 n 到数字 m 之间(包含 n 和 m)有多少个数字 d 出现,下列程序哪个能够实现( )。
- A. ```cpp
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;
- **B.** ```cpp
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;
- C. ```cpp
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;
- **D.** ```cpp
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;