C 练习实例75

C 语言教程 · 2019-02-22 12:44:15

题目:输入一个整数,并将其反转后输出。

程序分析:无。

实例 - 使用 strlen()

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // #include <stdio.h> int main() { int n, reversedNumber = 0, remainder; printf("输入一个整数: "); scanf("%d", &n); while(n != 0) { remainder = n%10; reversedNumber = reversedNumber*10 + remainder; n /= 10; } printf("反转后的整数: %d", reversedNumber); return 0; }

以上实例运行输出结果为:

输入一个整数: 12345
反转后的整数: 54321

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

具体数学(英文版第2版)

具体数学(英文版第2版)

[美] Ronald L. Graham、Donald E. Knuth、Oren Patashnik / 机械工业出版社 / 2002-8 / 49.00元

This book introduces the mathematics that supports advanced computer Programming and the analysis of algorithms. The primary aim of its well-known authors is to provide a solid and relevant base of ma......一起来看看 《具体数学(英文版第2版)》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试