本文介绍了给定一个数字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的相等数组成。
发布评论