给定一个数字x找到大于x的下一个数字,由4和7的相等数组成。

编程入门 行业动态 更新时间:2024-10-11 09:19:29
本文介绍了给定一个数字x找到大于x的下一个数字,由4和7的相等数组成。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

输入 - 输出 例如-3217 -4477 147 - 174 160 - 174 我尝试了什么: 1)如果所有数字按降序排序,则输出始终为不可能。例如,4321. 2)如果所有数字按升序排序,那么我们需要交换最后两位数字。例如,1234。 3)对于其他情况,我们需要从最右边处理数字(为什么?因为我们需要找到所有更大数字中最小的数字)

Input - Output Eg -3217 -4477 147 - 174 160 - 174 What I have tried: 1) If all digits sorted in descending order, then output is always "Not Possible". For example, 4321. 2) If all digits are sorted in ascending order, then we need to swap last two digits. For example, 1234. 3) For other cases, we need to process the number from rightmost side (why? because we need to find the smallest of all greater numbers)

推荐答案

这是HomeWork,所以制作程序是你的任务。 当你问别人有关你的HomeWork的问题时,至少发布问题的真实陈述。这将避免像这样的疯狂情况,你的陈述有 5个矛盾或不一致。 例如:4321,我不知道看看为什么4327或4477不是一个有效的答案。 This is HomeWork, so it is your task to produce a program. When you ask someone else a question about your HomeWork, at least post the real statements of the problem. It will avoid crazy situations like this one, where your statements have 5 contradictions or inconsistencies. Ex: for 4321, I don't see why 4327 or 4477 wouldn't be a valid answer.

更多推荐

给定一个数字x找到大于x的下一个数字,由4和7的相等数组成。

本文发布于:2023-11-29 10:15:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646108.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!