当前位置:网站首页>C语言试题166之整数逆序输出
C语言试题166之整数逆序输出
2022-06-09 21:35:00 【码莎拉蒂 .】
个人主页:个人主页
系列专栏:C语言试题200例
推荐一款刷算法、笔试、面经、拿大公司offer神器 点击跳转进入网站
作者简介:大家好,我是码莎拉蒂,CSDN博客专家(全站排名Top 50),阿里云博客专家、51CTO博客专家、华为云享专家
1、题目
题目:将一个从键盘输入的整数存放到一个数组中,通过程序的运行按照数组中的逆序输出该整数,利用递归的方法解决问题。
分析:
设计函数实现数据的逆序存放,设定形参数组接收实参数组的地址,来存储数据的每一位。函数体采用递归的方式解决问题,因此考虑递归进行的条件。例如,把数据 n 存放到数组 s 中,若 n 是一位数,则存放 n 到数组中;若 n 不是一位数,则存放 n/10 到数组中。
问题解决的难点在于找到数据的存放地址,通过不断地取余和整除 10 来得到数据的每一位。为了实现数据的逆序存放,每一次整除 10 的时候,同时把存放数据的数组地址后移,这样得到的第一位数存放在数组的最后一位……通过依次前移,即递归的回归,实现整个数据的存放。通过函数 convert() 实现字符串中的数字的逆序转换。
边栏推荐
- SPIDER Pi Intelligent Vision hexapode Robot VNC Connect Robot 0603
- Cremb Pro backend sub administrator 403 problem analysis
- 怎么查期货平台是不是安全的?正规性怎么查
- Second cloud cloud's original fully compatible solution for information innovation promotes the acceleration of the implementation of information innovation industry
- Digital engineering construction enterprises carry out "safety production month" activities in this way
- Cookies and session workflows
- Spider PI intelligent vision hexapod robot tag recognition apirltag tag 0604
- Spider PI intelligent vision hexapod robot color recognition function 0603
- Bonner radar sensor q120raq-cn-af19719
- Function object (functor)
猜你喜欢

Discussion on solving LCA by multiplication method

RCNN系列总结

化工企业双重预防体系数字化综合管理系统

Audio 3A processing practice makes your application more "pleasant"

spider pi 智能视觉六足机器人 开机介绍 0602

Digital integrated management system of double prevention system in chemical enterprises

BLE链路层空中包格式

尽一份孝心,为家人做一个老人防摔报警系统

TL, how do you manage project risks?

Actions before purchasing memory modules
随机推荐
【翻译论文】A Progressive Morphological Filter for Removing Nonground Measurements From Airborne LIDAR Dat
实验一:在FW上配置静态路由实现互通
Spider PI intelligent vision hexapod robot tag recognition apirltag tag 0604
86. (leaflet house) leaflet military plotting - collection of linear arrows
校园锐捷路由器使用指南
Digital integrated management system of double prevention system in chemical enterprises
JS cast and implicit type conversion and Unicode encoding
第四范式陈雨强:企业智能决策的下一代技术「强化学习 + 环境学习」
易买网开发 趣买买 项目资源一览 0605
scratch编程 飞翔的小鸟 开发笔记 0604
TL,你是如何管理项目风险的?
稍微复杂的查询
Oracle paging
What is fitness?
基础查询语句
ST-Link V2 下载出现:internal command error&Error: Flash Download failed - Target DLL has been cancelled
Day6-t1345 & T39 -2022-01-21-not answer by yourself
RCNN系列总结
河北恒银期货是正规平台吗?安全吗?
Spider PI intelligent vision hexapod robot in direct connection mode 0603