需要一些javabats的帮助 [英] Need help with a few javabats

查看:65
本文介绍了需要一些javabats的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要几个javabats的帮助。


1)http://javabat.com/prob?id=String3.sumNumbers

i need help with a couple of javabats.

1) http://javabat.com/prob?id=String3.sumNumbers

展开 | 选择 | Wrap | 行号

推荐答案

我只是看第一个练习 - sumNumbers。你的代码似乎是随机的,就像你从之前的练习中复制它一样。首先,您将字母和数字复制到第二个字符串(为什么?)并且对结果字符串不执行任何操作,然后您似乎在对原始字符串中的数字进行求和。看看其中一个例子:


sumNumbers(" aa11b33")→44


如果你将数字相加它将是1 + 1 + 3 + 3 = 8,而不是11 + 33 = 44.


我建议你从伪代码开始 - 你如何用简单的步骤描述这个操作的解决方案?
I''m just looking at the first exercise -- sumNumbers. your code seems rather random, like you copied it from an earlier exercise. First you copy letters and digits to a second string (why?) and do nothing with the resulting string, then you seem to be summing up the digits in the original string. Take a look at one of the examples:

sumNumbers("aa11b33") → 44

If you summed the digits it would be 1 + 1 + 3 + 3 = 8, not 11 + 33 = 44.

I suggest you start with pseudo code -- how you you describe the solution to this operation in simple steps?



我只是看第一个练习 - sumNumbers。你的代码似乎是随机的,就像你从之前的练习中复制它一样。首先,您将字母和数字复制到第二个字符串(为什么?)并且对结果字符串不执行任何操作,然后您似乎在对原始字符串中的数字进行求和。看看其中一个例子:


sumNumbers(" aa11b33")→44


如果你将数字相加它将是1 + 1 + 3 + 3 = 8,而不是11 + 33 = 44.


我建议你从伪代码开始 - 你如何用简单的步骤描述这个操作的解决方案?
I''m just looking at the first exercise -- sumNumbers. your code seems rather random, like you copied it from an earlier exercise. First you copy letters and digits to a second string (why?) and do nothing with the resulting string, then you seem to be summing up the digits in the original string. Take a look at one of the examples:

sumNumbers("aa11b33") → 44

If you summed the digits it would be 1 + 1 + 3 + 3 = 8, not 11 + 33 = 44.

I suggest you start with pseudo code -- how you you describe the solution to this operation in simple steps?



是的,我忘了把ret字符串放在另一种方法中。对于像7 11这样的字符串,它有一个空格,所以我想压缩它。是的,我明白你的意思。


首先,我会检查每个字符,看看它是否是一个int。然后我必须做一些事情,检查它是否是一个两位数或一位数,我在那里遇到麻烦


yeah, i forgot to put ret string in the other method. For a string like "7 11", it has a space in it, so I want to condense it. Yeah, i see what u mean.

First I would check each char and see whether or not it is a int. then i have to do something ot check whether or not it is a double digit or a single digit, im having some trouble there



First我会检查每个char并查看它是否是int。然后我必须做一些事情,检查它是否是一个两位数或一位数,我有一些麻烦
First I would check each char and see whether or not it is a int. then i have to do something ot check whether or not it is a double digit or a single digit, im having some trouble there



三位数,四位数,... 。Hello123World4567Example


一直在考虑它,直到你提出的解决方案对你更清楚。

Triple digits, quadruple digits, ... "Hello123World4567Example"

keep thinking about it until your proposed solution is clearer to you.


这篇关于需要一些javabats的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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