实验3(函数)参考程序

上传人:ji****72 文档编号:35897321 上传时间:2018-03-22 格式:DOC 页数:4 大小:42.50KB
返回 下载 相关 举报
实验3(函数)参考程序_第1页
第1页 / 共4页
实验3(函数)参考程序_第2页
第2页 / 共4页
实验3(函数)参考程序_第3页
第3页 / 共4页
实验3(函数)参考程序_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《实验3(函数)参考程序》由会员分享,可在线阅读,更多相关《实验3(函数)参考程序(4页珍藏版)》请在金锄头文库上搜索。

1、7、参考程序、参考程序 #include /N5003.cpp using namespace std; double power (double x, int n); void main(void) int i; int value = 0; char ch; cout = 0; i-) cin ch; if (ch = 1) value += int(power(2,i); cout using namespace std; void main() double a,b;double arctan(double x) ; /函数原型声明函数原型声明a=16.0*arctan(1/5.0)

2、; b=4.0*arctan(1/239.0) ; /注意:因为整数相除结果取整,注意:因为整数相除结果取整,/如果参数写如果参数写 1/5,1/239,结果就都是,结果就都是 0cout1e-15)f=e/i;r=(i%4=1)? r+f : r-f ;e=e*sqr; i+=2;return r ; 9、#include using namespace std; void main() bool symm(long n);long m;for(m=11; m #include using namespace std; int rolldice(void); void main() int

3、gamestatus,sum,mypoint;unsigned seed; coutseed; /输入随机数种子输入随机数种子srand(seed); /将种子传递给将种子传递给 rand()sum=rolldice(); /第一轮投骰子、计算和数第一轮投骰子、计算和数 switch(sum)case 7: /如果和数为如果和数为 7 或或 11 则为胜则为胜,状态为状态为 1case 11: gamestatus=1;break;case 2: /和数为和数为 2、3 或或 12 则为负则为负,状态为状态为 2case 3: case 12: gamestatus=2;break;default: /其它情况其它情况,游戏尚无结果游戏尚无结果,状态为状态为 0,记下点数记下点数,为下一轮做准备为下一轮做准备gamestatus=0;mypoint=sum ;cout using namespace std; void main() int n,k;int comm(int n, int k);cinnk;coutn ) return 0;else if( n=k|k=0 )return 1;elsereturn comm(n-1,k)+comm(n-1,k-1) ;

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号