当前位置:网站首页>刷题-洛谷-P1307 数字反转
刷题-洛谷-P1307 数字反转
2022-08-04 19:44:00 【宋向上_UP】
P1307 数字反转-C语言
1、题目
2、求解过程
结果:
代码:
//洛谷 1307 数字反转
#include <stdio.h>
#define NUM 10//最多有十位
int main() {
long n;
long m=0;//反转后的数字
int i,j;
int counter=0;//计数器 整数的位数
long position[NUM];//存放每一位的值
scanf("%ld", &n);//输入整数N
while(n!=0){
position[counter] = n % 10;
counter++;//计算位数
n = n / 10;
}
/* printf("counter的值为%d 取出每位的值:\n",counter); for (i = 0; i < counter; i++) { printf(" %ld ", position[i]); } printf("\n");*/
for (i = 0; i < counter-1; i++) {
for (j = 0; j <=i; j++) {
position[j] = position[j] * 10;
}
}
for (i = 0; i < counter; i++) {
m = position[i] + m;
}
printf("%ld", m);
return 0;
}
边栏推荐
- v-model的使用
- Embrace the Cmake child is simple and practical, but inflexible
- 从卖产品到卖“链路”:20条策略 解读直播带货迭代玩法
- Video Object Detection
- Use "green computing" technology to promote sustainable development of computing power
- How to promote the implementation of rural revitalization
- 哈佛架构 VS 冯·诺依曼架构
- How to monitor code cyclomatic complexity by refactoring indicators
- 手把手教你CSP系列之script-src
- 03 ts类型缩小,函数
猜你喜欢
TritonVM——基于Recursive STARK的虚拟机
Yuanguo chain game system development
使用.NET简单实现一个Redis的高性能克隆版(二)
基于HDF的LED驱动程序开发(2)
In July 2022, domestic database memorabilia
Jmeter - Heap配置原因报错Invalid initial heap size: -Xms1024m -Xmx2048mError
Ant Group's time series database CeresDB is officially open source
如何推动乡村振兴的落地
Go学习笔记(篇一)配置Go开发环境
Pedestrian fall detection experiment based on YOLOV5
随机推荐
成品升级程序
力扣题(5)—— 最长回文子串
华为WLAN技术:AP上线及相关模板的配置实验
Force KouTi (5), the longest text string back
The establishment of simple data cache layer
完善的交叉编译环境记录 peta 生成的shell 脚本
宏定义小方法
Pedestrian fall detection experiment based on YOLOV5
哈佛架构 VS 冯·诺依曼架构
Finished product upgrade program
Regular expression is incomplete
致-.-- -..- -
Ant Group's time series database CeresDB is officially open source
污损指纹恢复与识别
工业相机CCD与CMOS
Zip4j使用
openharmony代码框架初识(2)
The list of Kubernetes - watch mechanism
一些性能测试的要点
面试官:JVM运行时数据区包含哪几部分?作用是啥?