递归,输出倒序数

#include<stdio.h>
int n;
int zhd(int n)
{
 if(n<10)
    return n;
 else   
    return zhd(n%10); 
}
int main()
{
 int n;
 scanf("%d",&n);
 while(n!=0)
 {
  printf("%d",zhd(n));
  n=n/10;
 }
 return 0;
}

时间: 2024-08-16 17:01:05

递归,输出倒序数的相关文章

HDU5092——DP+递归输出——Seam Carving

Problem Description Fish likes to take photo with his friends. Several days ago, he found that some pictures of him were damaged. The trouble is that there are some seams across the pictures. So he tried to repair these pictures. He scanned these pic

dp-LCS(递归输出最短合串)

Problem Description The company "21st Century Fruits" has specialized in creating new sorts of fruits by transferring genes from one fruit into the genome of another one. Most times this method doesn't work, but sometimes, in very rare cases, a

Java 递归输出文件

import java.io.File;public class TestAddressSet {************递归输出文件下的所有目录**********    public static void main(String[] args) {        // TODO Auto-generated method stub        File file= new File("E:/张敬轩");        myList(file);    } private sta

Java递归输出指定路径下所有文件及文件夹

package a.ab; import java.io.File; import java.io.IOException; public class AE { public static void main(String[] args) { File f=new File("D:\\DD"); new AE().fileList(f); } public void fileList(File fl){ try{ File[] fs=fl.listFiles(); for(File f

uva 10453 Make Palindrome (区间DP + 递归输出)

uva 10453 Make Palindrome 题目大意:给出一段字符串,要求求出最少加入几个字符(任意位置),可以让该字符串变成会问字符串,并输出修改以后的回文字符串. 解题思路:dp[i][j]代表了将该字符串从第i位到第j位变成回文字符串最少要添加的字符.当S[i]==S[j],dp[i][j]=dp[i+1][j?1]当S[i]!=S[j],dp[i][j]=min(dp[i+1][j],dp[i][j?1])+1,在DP的过程中记录对该区间的操作类型,最后递归输出. #includ

递归输出二叉树的每个结点

算法导论:10.4-2 给定一个二叉树,写出一个 O(n) 时间的递归过程,将该树每个结点的关键字输出. #ifndef _BINARY_TREE_H_ #define _BINARY_TREE_H_ /***************************************************** 算法导论:10.4-2 一个二叉树,使用递归输出每个结点 ******************************************************/ #include

IO-08. 输出倒三角图案(for循环写的不符合,用笨笨的println,%&gt;_&lt;%)

本题要求编写程序,输出指定的由“*”组成的倒三角图案. 输入格式:本题目没有输入. 输出格式:按照下列格式输出由“*”组成的倒三角图案. * * * * * * * * * *注意:严格按照下面截图的样式. 无奈用for循环写不出,只好用笨笨的println一行行的输出了. public class Main { public static void main(String[] args) { System.out.println("* * * *"); System.out.prin

递归输出字符串 经典中的经典

#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> void f(char *p) { if (*p == '\0') { return; } else { f(p + 1); printf("%c\n", *p); } } void main() { char *p = "abcd"; f(p); system("pause"); }

浙大版《C语言程序设计(第3版)》题目集 练习2-3 输出倒三角图案 (5 分)

练习2-3 输出倒三角图案 (5 分) 本题要求编写程序,输出指定的由"*"组成的倒三角图案. 输入格式: 本题目没有输入. 输出格式: 按照下列格式输出由"*"组成的倒三角图案. * * * * * * * * * *思路:格式化输出,注意换行.代码如下: #include<stdio.h> int main () { printf("* * * *\n"); printf(" * * *\n"); printf