本文介绍了c程序用于反转数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找用于反转数字的 C
程序,如下所示:
I am looking for the C
program for reverse the digits like below:
如果我输入:
123456
那么结果将是:
654321
请帮帮我.
推荐答案
使用 % 10
获取最后一位数字.输出它.将数字除以 10 以获得除最后一位之外的所有数字.使用 % 10
获得最后一位数字.依此类推,直到数字变为 0.
Use % 10
to get the last digit. Output it. Divide the number by 10 to get all but the last digit. Use % 10
to get the last digit of that. And so on, until the number becomes 0.
这篇关于c程序用于反转数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!