当前位置:   article > 正文

数字反转c语言程序_程序在C ++中反转数字

数字反转c++

数字反转c语言程序

Here you will get program to reverse number in C++.

在这里,您将获得使用C ++反转数字的程序。

  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. long n,rev=0,d;
  8. cout<<"Enter any number:";
  9. cin>>n;
  10. while(n!=0)
  11. {
  12. d=n%10;
  13. rev=(rev*10)+d;
  14. n=n/10;
  15. }
  16. cout<<"The reversed number is "<<rev;
  17.  
  18. return 0;
  19. }

Output

输出量

Enter any number:12674 The reversed number is 47621

输入任意数字:12674 反向数字为47621

翻译自: https://www.thecrazyprogrammer.com/2012/11/c-program-to-reverse-number.html

数字反转c语言程序

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/article/detail/60513
推荐阅读
相关标签
  

闽ICP备14008679号