Java发现缺少数字的问题 [英] Java finding a missing number problem

查看:129
本文介绍了Java发现缺少数字的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要解决一个关于java的问题。用户提供一个包含数字的字符串。缺少其中一个数字。第一个和最后一个数字可以介于-9999和9999之间,差异可以在-99到99之间。我的程序应该打印缺少的数字。

以下是一些例子:



510152030

25



567566565564563562561560559557556555554

558



828588919497100103106112115118121

109



-45-35-25-55152535455565
-15



我只掌握java的基本知识。(而且,for,if)

我不喜欢我想使用休息,继续,开关



我将非常感谢你的帮助...



< b>我尝试了什么:



我无法尝试任何东西,因为我的代码太长了。

解决方案

Google [ ^ ]是你的朋友!



第一个结果:找到遗失的号码 - 极客怪人 [ ^ ]





对于缺少的数字字符串,请检查:在没有分隔符的数字字符串中查找缺少的数字 - GeeksforGeeks [ ^

Hello guys,
There is a problem about java i need to solve. The user provides a string which has numbers in it. One of the numbers is missing. The first and the last number can be between -9999 and 9999 and the difference can be between -99 and 99. My program should print the missing number.
Here are some examples:

510152030
25

567566565564563562561560559557556555554
558

828588919497100103106112115118121
109

-45-35-25-55152535455565
-15

I only have a basic knowledge in java.( while,for,if)
I don't want to use break,continue,switch

I would appreciate your help...

What I have tried:

I could not try anything because my code gets too long.

解决方案

Google[^] is your friend!

First result: Find the Missing Number - GeeksforGeeks[^]

[EDIT]
For missing numbers in string, check this: Find the missing number in a string of numbers with no separator - GeeksforGeeks[^]


这篇关于Java发现缺少数字的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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