当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
- JS手写JSON.stringify() (面试)
- 华为企业组网实例:VRRP+MSTP典型组网配置
- 基于YOLOV5行人跌倒检测实验
- T+Cloud: A "Smart Company" for Building New Business Social Networks and Marketing Relationships
- MMDetection usage example: from entry to exit
- 按需视觉识别:愿景和初步方案
- 泰山OFFICE技术讲座:底纹、高亮、边框的关系
- MYSQL获取数据库的表名和表注释
- In July 2022, domestic database memorabilia
- 污损指纹恢复与识别
猜你喜欢

基于YOLOV5行人跌倒检测实验

IIC驱动OLED

JS new一个构造器发生了什么?从零手写一个new方法

Use "green computing" technology to promote sustainable development of computing power

MogDB学习笔记-环境准备及单实例安装

Infrared image filtering

华为企业组网实例:VRRP+MSTP典型组网配置
![[Sql brush topic] Query information data--Day1](/img/a7/67b59bd41803dfc07ecb8f00669c29.png)
[Sql brush topic] Query information data--Day1

Query the published version records of the APP Store

污损指纹恢复与识别
随机推荐
ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
【Attention 演变史】RNN的产生、架构、推广、问题(第一弹)
Ant Group's time series database CeresDB is officially open source
前3名突然变了,揭秘 7 月编程语言最新排行榜
AWS SES 的监控和告警
入门:人脸专集1 | 级联卷积神经网络用于人脸检测(文末福利)
【有奖征文】秋招特训,打造你的专属产品体验
String中的hashcode缓存以及HashMap中String作key的好处
Query the published version records of the APP Store
如何使用 jMeter Parallel Controller - 并行控制器以及一些常犯的错误
[Latest Information] 2 new regions will announce the registration time for the soft exam in the second half of 2022
元国度链游系统开发
Client Side Cache 和 Server Side Cache 的区别
Storage resource activation system to help new infrastructure
【ASP.NET Core】 中间件
JSD-2204-酷莎商城(管理员模块)-密码加密-Day10
"WAIC 2022 · hackers marathon" two ants wealth competition invited you to fight!
IIC驱动OLED
视频目标检测
SAP UI5 确保控件 id 全局唯一的实现方法