首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
codesuc
2020年3月2日 22:51
循环统计每个数中2数量
P1002
回复 5
|
赞 1
|
浏览 13.6k
#include int main(){ int a,b,c=0; scanf("%d %d",&a,&b); for(int i=a;i<=b;i++){ if(i==2) c++; else{ for(int j=i;j>0;j=j/10){ if(j%10==2) c++; } } } prin...
猛士骁将
2020年3月10日 18:52
1002 - 数字统计
P1002
回复 0
|
赞 1
|
浏览 12.3k
把从L到R的每个数,先对10取余数,结果放入变量yu中,在对10整除结果放入变量value中,重复这个操作,就把一个数的每位拆出来了,同时统计2的个数 #include <stdio.h> int main() { int L = 0, R = 0, value= 0,yu = 0, num = 0; scanf("%d %d", &L, &R); while (L <= R) &nb...
王华瑞
2020年1月20日 23:29
解
P1002
回复 0
|
赞 2
|
浏览 13.1k
#include<stdio.h> int main() { int a,b,d,c,n,i,j; d=0; scanf("%d %d",&a,&b); for(i=a;i<=b;i++) { c=i; ...
A1120161820
2020年3月18日 10:15
数字统计(c++)
P1002
回复 0
|
赞 2
|
浏览 11.5k
#include<iostream> using namespace std; int main() { int L, R; while (cin >> L >> R) {//EOF结束输入 int ans = 0;//计数 for (int num = L; num <= R; num++) { int tmp = num; while (tmp > 0) { if (tmp%10 == 2) ans++; tmp /= 10; } } ...
mzymzyo
2020年2月18日 19:38
数字统计
P1002
回复 4
|
赞 0
|
浏览 12.4k
#include<iostream> using namespace std; int main() { long long L, R, ans = 0;/*ans用来统计2出现的次数,要初始化为0*/ cin >> L >> R; for (int i = L; i <= R; i++) { int j ...
1
2
3
4
题目
数字统计
题解数量
35
发布题解
在线答疑
热门题解
1
数字统计 题解:转string暴力破
2
数字统计 题解:
3
数字统计 题解:简洁c++
4
数字统计 题解:
5
数字统计 题解:
6
P1002 - 数字统计 - C
7
数字统计 题解:为什么使用前缀和只有70%ac
8
给出左右边界,统计2出现次数
9
c++ 1002 方法:整型转换为字符串类型
10
数字统计 题解:暴力