关注吃喝新鲜事 优惠早知道
X扫一扫,关注吃喝微信订阅号

吃喝玩乐网官方微信订阅号:
成都吃喝玩乐网

  • 无缝对接网站,实时在线,热闹无边
  • 新鲜讯息推送,及时送达
  • 福利折扣优惠送送送
  • 微信里的吃喝玩乐
X扫一扫,关注吃喝微信服务号

吃喝玩乐网官方微信服务号:
吃喝玩乐网

  • 无缝对接网站,实时在线,热闹无边
  • 新鲜讯息推送,及时送达
  • 功能强大的福利折扣优惠活动
  • 微信里的吃喝玩乐

[居家常备] 吃喝人才多,来看哈一年级的题

 
gege88
UID 570148
发表于 2022-6-18 13:25 | 显示全部楼层 来自: 四川省成都市 电信
    var total=0, //初始化计数器
        min=60, //定义下限
        max=80; //定义上限
    var result=[];//结果容器
    min++; //之间表示要去掉两头
    for (var i=min; i< max ;i++){
            //来个循环 从下限+1开始 大于等于上限就结束
        var shiwei=parseInt( i/10); //十位
        var gewei=i%10;//个位
        if (2==Math.abs(gewei-shiwei)){
                //如果个位和十位相差2 就存起来 绝对值哦
            result.push(i);
            total++;
        }
    }
    //结果输出
    console.log(total+"个:");
    console.log(result);

1655530815447.jpg



yql830410
UID 923913
发表于 2022-6-18 13:35 来自手机 | 显示全部楼层 来自: 四川省成都市 联通
gege88 发表于 2022-06-18 13:25
&nbsp; &nbsp; var total=0,
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;min=60,
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;max=80;
&nbsp; &nbsp; var result=[];
&nbsp; &nbsp; for (var i=min; i&lt; max ;i++){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var shiwei=parseInt( i/10);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var gewei=i%10;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (2==Math.abs(gewei-shiwei)){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;result.push(i);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;total++;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}
&nbsp; &nbsp; }
&nbsp; &nbsp; console.log(total+&quot;个:&quot;);
&nbsp; &nbsp; console.log(result);

人才
gege88
UID 570148
发表于 2022-6-18 13:42 | 显示全部楼层 来自: 四川省成都市 电信

上了一年级的都知道。
wjpower
UID 584516
发表于 2022-6-18 13:47 来自手机 | 显示全部楼层 来自: 四川省成都市 电信
COCO118
UID 966289
发表于 2022-6-18 13:58 来自手机 | 显示全部楼层 来自: 四川省成都市 移动
gege88 发表于 2022-06-18 13:25
&nbsp; &nbsp; var total=0, //初始化计数器
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;min=60, //定义下限
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;max=80; //定义上限
&nbsp; &nbsp; var result=[];//结果容器
&nbsp; &nbsp; min++; //之间表示要去掉两头
&nbsp; &nbsp; for (var i=min; i&lt; max ;i++){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//来个循环 从下限+1开始 大于等于上限就结束
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var shiwei=parseInt( i/10); //十位
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var gewei=i%10;//个位
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (2==Math.abs(gewei-shiwei)){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; //如果个位和十位相差2 就存起来 绝对值哦
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;result.push(i);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;total++;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}
&nbsp; &nbsp; }
&nbsp; &nbsp; //结果输出
&nbsp; &nbsp; console.log(total+&quot;个:&quot;);
&nbsp; &nbsp; console.log(result);

啥子鬼东西
造孽的娃
UID 893869
发表于 2022-6-18 14:00 来自手机 | 显示全部楼层 来自: 四川省成都市 电信
gege88 发表于 2022-06-18 13:25
&nbsp; &nbsp; var total=0, //初始化计数器
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;min=60, //定义下限
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;max=80; //定义上限
&nbsp; &nbsp; var result=[];//结果容器
&nbsp; &nbsp; min++; //之间表示要去掉两头
&nbsp; &nbsp; for (var i=min; i&lt; max ;i++){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//来个循环 从下限+1开始 大于等于上限就结束
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var shiwei=parseInt( i/10); //十位
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var gewei=i%10;//个位
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (2==Math.abs(gewei-shiwei)){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; //如果个位和十位相差2 就存起来 绝对值哦
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;result.push(i);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;total++;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}
&nbsp; &nbsp; }
&nbsp; &nbsp; //结果输出
&nbsp; &nbsp; console.log(total+&quot;个:&quot;);
&nbsp; &nbsp; console.log(result);

秀!!!
蛋定哥1977
UID 601962
发表于 2022-6-18 14:02 来自手机 | 显示全部楼层 来自: 四川省成都市 电信
烟灬火 发表于 2022-06-18 13:10
小学应该没学负数吧

个位和十位上的数相差2。只要相差2就对了。都是大的减小的
发表于 2022-6-18 14:10 来自手机 | 显示全部楼层 来自: 四川省成都市 移动
gege88 发表于 2022-06-18 13:25
&nbsp; &nbsp; var total=0, //初始化计数器
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;min=60, //定义下限
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;max=80; //定义上限
&nbsp; &nbsp; var result=[];//结果容器
&nbsp; &nbsp; min++; //之间表示要去掉两头
&nbsp; &nbsp; for (var i=min; i&lt; max ;i++){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;//来个循环 从下限+1开始 大于等于上限就结束
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var shiwei=parseInt( i/10); //十位
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;var gewei=i%10;//个位
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (2==Math.abs(gewei-shiwei)){
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; //如果个位和十位相差2 就存起来 绝对值哦
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;result.push(i);
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;total++;
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}
&nbsp; &nbsp; }
&nbsp; &nbsp; //结果输出
&nbsp; &nbsp; console.log(total+&quot;个:&quot;);
&nbsp; &nbsp; console.log(result);

大材小用
ouyang911
UID 16805
发表于 2022-6-18 14:21 | 显示全部楼层 来自: 四川省成都市 电信
我来杠,应该是:60和80之间的“整数”
李大本事
UID 754453
发表于 2022-6-18 14:29 来自手机 | 显示全部楼层 来自: 四川省成都市 电信
这个算是比较简单了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

99元抢购蜀仁口腔 超声波舒适洁牙套餐

99.00

蜀仁洁牙福利来了! 成人超声波全口舒适化洁牙仅需99元!

去看看

老罗贴膜团购返场 700起到手价

49.00

新一季的老罗贴膜团购来了,前档+后档+侧窗实际到手价700起

去看看

金、银质感吃喝车标以及贴纸款车标上新 申购中

5.00

52CH车友会-车标金银、贴纸上新,顺丰直达

去看看

返回顶部 NewT 快速回复 返回列表 QQ