当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
猜你喜欢

"WAIC 2022 · hackers marathon" two ants wealth competition invited you to fight!

如何推动乡村振兴的落地

小软件大作用 | 如何省时省力进行Gerber图层快速对比?

How to monitor code cyclomatic complexity by refactoring indicators

openharmony初体验(1)

SQL Server 遇到报错解决办法--更新中

蚂蚁集团时序数据库CeresDB正式开源

The book "The Essence of Alipay Experience Design", a record of knowledge related to testing

Yuanguo chain game system development

运维就业现状怎么样?技能要求高吗?
随机推荐
完善的交叉编译环境记录 peta 生成的shell 脚本
T+Cloud: A "Smart Company" for Building New Business Social Networks and Marketing Relationships
Exploration and Practice of Database Governance
How to manually download and install SAP Fiori tools - Extension Pack for Visual Studio Code
"WAIC 2022 · hackers marathon" two ants wealth competition invited you to fight!
In July 2022, domestic database memorabilia
Openharmony code framework (2) the person that
LED的C语言应用程序
03 ts类型缩小,函数
电脑一键重装系统内存完整性无法打开怎么办
The book "The Essence of Alipay Experience Design", a record of knowledge related to testing
really time ntp服务启动命令
02 ts 变量定义,类型
指静脉识别-matlab
MYSQL获取数据库的表名和表注释
如何使用 jMeter Parallel Controller - 并行控制器以及一些常犯的错误
The difference between Client Side Cache and Server Side Cache
PG网络传输安全SSL介绍及使用示例
二叉树的前序遍历
PostgreSQL的 SPI_接口函数