当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
- 二叉树的遍历
- SQL Server 遇到报错解决办法--更新中
- JS new一个构造器发生了什么?从零手写一个new方法
- Zip4j使用
- To -.-- -..- -
- The difference between Client Side Cache and Server Side Cache
- Orthodontic MIA micro-implant anchorage technology China 10th anniversary exchange meeting was held in Shenyang
- TritonVM——基于Recursive STARK的虚拟机
- 二叉树是否对称
- MMDetection usage example: from entry to exit
猜你喜欢
随机推荐
高效目标检测:动态候选较大程度提升检测精度(附论文下载)
T+Cloud:构建新型生意社交网络和营销关系的“智公司”
JSD-2204-酷莎商城(管理员模块)-密码加密-Day10
MYSQL获取数据库的表名和表注释
Highlights of some performance tests
Aura clock chip generation configuration file script
SAP UI5 ensures that the control id is globally unique implementation method
如何使用 jMeter Parallel Controller - 并行控制器以及一些常犯的错误
【ASP.NET Core】 中间件
Spark提交参数说明和常见优化
How to promote the implementation of rural revitalization
拥抱Cmake小朋友 简单又实用,但是不灵活
Chrome 开发者工具 performance 标签页的用法
入门:人脸专集1 | 级联卷积神经网络用于人脸检测(文末福利)
openharmony代码框架初识(2)
对比几类主流的跨端技术方案
如何推动乡村振兴的落地
Order of lds links
Openharmony first experience (1)
面试官:JVM运行时数据区包含哪几部分?作用是啥?









