在 Java 中,如何将缩写整数转换为字符串中的整数?

发布于 2025-01-19 09:50:31 字数 281 浏览 0 评论 0原文

我有以下字符串作为我的输入:

(100m/10k) * 10k

m = 1,000,000
k = 1,000

我期望

(100000000/10000) * 10000

很难弄清楚如何用“真实整数”替换缩写整数。我已经尝试循环浏览字符串中的每个字符,并找到具有相应整数的字母并将其与整数相乘,但是我在字母前找到整数很难,然后替换/插入它在正确的位置。

I have the following string as my input:

(100m/10k) * 10k

where

m = 1,000,000
k = 1,000

I expect an output of

(100000000/10000) * 10000

I'm having a difficult time figuring out how to replace the abbreviated integers with "real integers". I've tried looping through each of the characters in the string and finding the letters that have a corresponding integer and multiplying them with the integer before it, but I'm having trouble with finding the integer before the letter, and replacing/inserting it in the correct spot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文