帮助一个循环,假设删除所有非数字 [英] Help with a loop that's suppose to remove all non-digits

查看:33
本文介绍了帮助一个循环,假设删除所有非数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个问题,解释为什么这个循环会做它的作用。

展开 | 选择 | Wrap | 行号

解决方案

因为即使当前字符被删除,x也会递增。如果它后面的字符是破折号,则它保留在字符串中。


@ milk242


Don当你刚删除一个非数字时,不要增加x。


亲切的问候,


Jos


感谢你们两位的解释和解决方案!


我做了我的新循环:

展开 | 选择 | Wrap | 行号

Hi,

I''m having a problem explaining why this loop does what it does.

Expand|Select|Wrap|Line Numbers

解决方案

Because x is incremented even if current character is erased. If character after it is the dash, it remains in string.


@milk242

Don''t increment x when you''ve just removed a non-digit.

kind regards,

Jos


Thanks to both of you for the explanation and solution!

I made my new loop:

Expand|Select|Wrap|Line Numbers


这篇关于帮助一个循环,假设删除所有非数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆