题库 C++/C语言题库 题目列表 想要计算从数字n到数字m之间(包含n和m)有多少个数字...
单选题
想要计算从数字n到数字m之间(包含n和m)有多少个数字d出现,下列程序哪个能够实现( )。
A.

1 int n,m,res,d; 
2 cin >> n >> m>>d; 
3 for(int i = n+1; i <= m; i++){ 
4  int temp = i; 
5  while(temp){ 
6   if(temp % 10 == d) res++; 
7   temp /= 10; 
8  } 
9 } 
10 cout << res << endl; 
11 return 0;
B.

1 int n,m,res,d; 
2 cin >> n >> m>>d; 
3 for(int i = n; i <= m; i++){ 
4  int temp = i; 
5  while(temp){ 
6   if(temp % 10 = d) res++; 
7   temp /= 10; 
8  } 
9 } 
10 cout << res << endl; 
11 return 0;
C.
1 int n,m,res=0,d;
2 cin >> n >> m>>d;
3 for(int i = n; i <= m; i++){
4  int temp = i;
5  while(temp){
6   if(temp % 10 == d) res++;
7   temp /= 10;
8  }
9 }
10 cout << res << endl;
11 return 0;
D.

1 int n,m,res=0,d; 
2 cin >> n >> m>>d; 
3 for(int i = n; i <= m; i++){ 
4  while(temp){ 
5   if(temp % 10 == d) res++; 
6   temp /= 10; 
7  } 
8 } 
9 cout << res << endl; 
10 return 0;
题目信息
2024年 三级 选择题
-
正确率
0
评论
60
点击