- 1、本文档共11页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
课本上的典型例题(A typical example of the textbook)
课本上的典型例题(A typical example of the textbook)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
想输出以下的结果,用函数调用实现。
***********************
你好吗?
***********************
#包括 stdio. h
无效main()
{
无效print_star();/ /声明print_star函数
无效print_message();/ /声明print_message函数
print_star();/ /调用print_star函数
print_message();/ /调用print_message函数
print_star();
}
无效print_star() /定义print_star函数
{
printf(“*************** \n”);
}
无效print_message() /也是定义函数
{
printf(“你是如何!\n”);
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
从键盘输入两个数,用调用函数来找出其中较大的那一个并输出。
#包括 stdio. h
无效main()
{
int max(x,y);/ /调用最大函数
printf(“请输入两个整数:\n”);
a,b;
scanf(“%d %d”,, B);
printf(“两个数中较大的是:%d\n”,max(A,B));
}
int max(x,y)/定义最大函数
{
返回x y?X:Y;/ /函数的返回值是该表达式的值
}
/ *定义最大函数还可以为:
int max(x,y)
{
int Z =(X>Y?X:Y);
返回Z;/ /因为最大必须有一个返回值,故需要用返回将值返回给最大函数
} /*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
用递归方法求n!。
#包括 stdio. h
国际main()
{
智力因素(int n);
int n;
y;
printf(“输入一个整数:”);
scanf(“%d”,和N);
Y = FAC(N);
printf(“%d!= %d\n”,N,Y);
返回0;
}
智力因素(int n)
{
int F;
如果(n<0)
printf(“N<0,日期错误!”);
如果(n = = 0 | | n = = 1)
F = 1;
其他的F = FAC(n-1)×N;
返回F;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
河内(汉诺)塔问题。这是一个古典的数学问题,是一个用递归方法解题的典型例子,问题是这样的:古代有一个梵塔,塔内有三个座,A,B,C,开始时一座上有64个盘子,盘子大小不等,大的在下,小的在上。有一个老和尚想把这64个盘子从一座移到C座,但规定每次只允许移动一个盘,且在移动过程中可以利用座要求编程序输出移动盘子的步骤B。
#包括 stdio. h
国际main()
{
void hanoi (int n, char char char one, two, three);
int m;
printf (input the number of dished:);
scanf (% d, m);
printf (the step to move% d dished: \ n , m);
hanoi (m, a, b, c);
}
void hanoi (int n, char char char one, two, three)
{
void move (char x, char y);
if (n = = 1)
move (one, three);
else
{
hanoi (n - 1, one, three, two);
move (one, three);
hanoi (n - 1, two, one, three);
}
}
void move (char x, char y)
{
printf (% c - % c \ n, x, y);
}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
您可能关注的文档
- 红色警戒3苏联战役全攻略(Red Alert 3 Soviet campaign Raiders).doc
- 红楼梦借助于音响渲写人物的鲜明性格(A dream of red mansions with distinctive character to sound out write characters).doc
- 纪检挂职副书记上半年个人工作总结(Deputy Secretary of the discipline inspection work in the first half of personal work summary).doc
- 纯水机的预处理渗透功能的详细介绍)(With the pretreatment of penetration function of pure water machine)).doc
- 纲要第六章练习题2011.12.18(The outline of the sixth chapter exercises 2011.12.18).doc
- 纳税流程(Tax process).doc
- 纸上谈兵也精彩-- 也谈英语作业中的评语(Empty talk is also wonderful -- on English homework in the comments).doc
- 素质拓展训练项目(To expand the quality of training project).doc
- 纺织常用英语(Textile English).doc
- 纺织概论测试题(An introduction to textile test).doc
- 读写例话教学的认识与实践_3697(Understanding and practice of _3697 reading and writing teaching cases. ).doc
- 课本介绍(Textbook Introduction).doc
- 课程整合的基本理念和策略(The basic idea and strategy of curriculum integration).doc
- 课程的设计理念与思路(Design concepts and ideas of curriculum).doc
- 调查与决策——《主动融入重庆经济圈 打造川渝合作桥头堡》文库(Investigation and decision making -- active integration into the Chongqing economic circle to build Chongqing cooperation bridgehead Library).doc
- 调查与决策——《主动融入重庆经济圈 打造川渝合作桥头堡》(Investigation and decision making -- active integration into the Chongqing economic circle to build Chongqing cooperation bridgehead).doc
- 说服力,让你的ppt会说话(Persuasive, let you speak ppt).doc
- 调查与决策——《对组建四川银行的构想》(Investigation and decision making -- idea of setting up the Bank of Sichuan).doc
- 课题解放战争的胜利发展(Topic the victory of the war of liberation and development).doc
- 调查与决策——《积极融入重庆经济圈 推进四川环渝腹地经济区发展》(Investigation and decision making -- actively integrating into Chongqing economic circle and promoting the development of Sichuan inner ring economic hinterland).doc
最近下载
- 八年级物理声现象单元测试卷.doc VIP
- 2025“安康杯”安全知识竞赛题库及参考答案(通用版版).docx VIP
- 2024宁波市海曙区事业单位历年考试真题.docx VIP
- 高考物理真题分类汇编-专题06运动和力的关系(原卷版).docx VIP
- 宁波市海曙区事业单位真题2023.docx VIP
- 悦纳自己——爱自己的100种方式(课件)高一下学期心理健康课(通用版).pptx VIP
- 浙江省消防技术规范难点问题操作技术指南-2025修订稿(定稿).docx
- 再生医学技术:2025年关节软骨修复研究前沿报告.docx
- 《电梯监督检验和定期检验规则》(TSG T7001-2023).docx VIP
- T CNAS 32─2023 注射相关感染预防与控制.pdf VIP
文档评论(0)