首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
blackbook537
2025年3月15日 21:09
数字统计 题解:
P1002
回复 0
|
赞 3
|
浏览 454
#include<stdio.h> #include<stdlib.h> #include<math.h> int countDigitTwo(int num){ int count = 0; while(num > 0){ if(num % 10 == 2){//查看个位数是否为2 &nbs...
诗岸梦行舟
2025年3月11日 15:23
数字统计 题解:
P1002
回复 0
|
赞 0
|
浏览 469
#include<stdio.h> #include<stdlib.h> int times; void suan(int lll,int rrr){ times=0; for(int i=lll;i<=rrr;i++){ int zanc=i; while(zanc){ if(zanc%10==2){ times++; } zanc/=10; } } } int main(){ int l,r; while(scanf("%d %d",&l,&...
西电机试专家
2025年3月10日 16:19
数字统计 题解:简单的思路
P1002
回复 0
|
赞 3
|
浏览 382
#include <bits/stdc++.h> using namespace std; int num2(int a){ int ans=0; while(a>0){ if(a%10==2) ans++; &n...
zxjrheaven
2025年3月9日 13:53
数字统计 题解:暴力
P1002
回复 0
|
赞 2
|
浏览 390
#include <bits/stdc++.h> using namespace std; int main() { int m,n; cin>>m>>n; int count=0; for(int i=m;i<=n;i++) { int a=i; ...
RingoCrystal
2024年4月3日 09:51
数字统计 题解:转string暴力破
P1002
回复 0
|
赞 6
|
浏览 1.1k
#include <bits/stdc++.h> using namespace std; int main(){ int l,r; while(cin>>l>>r){ int ans=0; for(int i=l;i<=r;i++){ string s=to_string(i); for(int j=0;j<s.size();j++){ if(s[j]=='2')ans++; } } cout<<ans<<endl; } retu...
lingdongyang
2024年3月18日 15:53
数字统计 题解:
P1002
回复 0
|
赞 4
|
浏览 1.6k
#include<stdio.h> int main() { int l = 0, r = 0; scanf("%d %d", &l, &r); int cnt = 0;//计数 //把i当作轮次,不然会死循环 for (int i = l; i <= r; i++) { int test = i; while (test) { //余数而不是除数 if (test % 10 == 2) { cnt++; } test = test / 10; } } ...
周小黑02477
2024年3月17日 00:16
为啥只有30%通过,想不明白
P1002
回复 1
|
赞 2
|
浏览 821
#include<stdio.h> #include<iostream> #include<string> #include<string.h> #include<math.h> #include<algorithm> using namespace std; int main() { int l, r; while (cin >> l >> r) { int count = 0; for (int i = l; i <= r; i++) ...
huanghu
2024年3月15日 12:21
数字统计 题解:简洁c++
P1002
回复 1
|
赞 5
|
浏览 868
#include<stdio.h> #include<iostream> using namespace std; int main(){ int L=0,R=0; cin>>L>>R; int count = 0; for(int i = L; i<=R;i++){ int t = i; while(t!=0){ if((t%10) == 2){ count++; ...
小酒
2024年3月11日 15:52
数字统计 题解:
P1002
回复 0
|
赞 1
|
浏览 973
1002解题思路 #include <bits/stdc++.h> using namespace std; int main() { int n,m,w; int count=0; scanf("%d %d",&n,&m); for(int i=n;i<=m;i++)  ...
Leee0809
2024年3月10日 22:45
数字统计 题解:
P1002
回复 0
|
赞 0
|
浏览 959
#include <stdio.h> #include <stdlib.h> int main() { //单独提取每一位数,然后与2进行比较,计数器计数 int L,R,a[6]; int CNT=0;//计数器 scanf("%d %d",&L,&R); for(int i=L;i<=R;i++) &n...
1
2
3
题目
数字统计
题解数量
28
发布题解
在线答疑
热门题解
1
数字统计 题解:转string暴力破
2
P1002 - 数字统计 - C
3
给出左右边界,统计2出现次数
4
数字统计 题解:简洁c++
5
数字统计 题解:
6
数字统计 题解:
7
c++ 1002 方法:整型转换为字符串类型
8
数字统计 题解:简单的思路
9
为啥只有30%通过,想不明白
10
数字统计 题解:暴力