当前位置:网站首页>《程序设计基础》 第十章 函数与程序结构 7-3 递归实现逆序输出整数 (15 分)
《程序设计基础》 第十章 函数与程序结构 7-3 递归实现逆序输出整数 (15 分)
2022-07-20 16:33:00 【茶然o】
本题目要求读入1个正整数n,然后编写递归函数reverse(int n)实现将该正整数逆序输出。
输入格式:
输入在一行中给出1个正整数n。
输出格式:
对每一组输入,在一行中输出n的逆序数。
输入样例:
12345
结尾无空行
输出样例:
54321
结尾无空行
#include <stdio.h>
#include <string.h>
int reverse(int n);
int main()
{
int n;
scanf("%d",&n);
int m=reverse(n);
return 0;
}
int reverse(int n){
int m;
if (n==0){
return 0;
}
m=n%10;
n=n/10;
printf("%d",m);
reverse(n);
}
边栏推荐
- C中的连接符##
- 416. 分割等和子集
- Tencent audio and video service experience
- Li Hongyi 2020 machine learning deep learning notes 1+2 & deep learning foundation and practice course notes 2
- Detailed explanation of class, classloder, Dex
- float的精度问题
- Influxdb query timestamp problem
- 单张RGB图估计3D手部姿态与形态
- 在同花顺上登录证券账号安全吗
- Typescript数值扩展使用
猜你喜欢
随机推荐
Wechat applet 02 Hello miniprogram
会员数继续下滑,Netflix能靠广告突围吗?
VMware low version starts the blue screen solution of virtual machine (it takes 3 days to restart the installation experience, which must be seen before installation)
微信小程序 20 完善视频页①
微信小程序 25 npm模块和PubSubJS实现页面通讯
Squeeze-and-Excitation Networks
VIM development environment configuration
Programmers are new to the workplace, how to plan their career?
高薪程序员&面试题精讲系列126之消息队列中积压了一百多万条消息怎么办?如何保证消息的一致性?
TNN笔记
C中的连接符##
Some easily confused pointers [summary direction]
MNN tutorials
Ncnn OP forward code learning
【2022华为开发者大赛系列直播】华为开发者大赛—乾坤云服务赛事解读
网络安全学习(三)基本DOS命令
Network Security Learning (IX) comprehensive experiment & PKI
Self study notes on Bayesian probability and Bayesian networks and Bayesian causal networks
在win7 64 上安装scikitlearn的悲惨经历
Wechat applet 05 obtains basic user information