资源描述:
《郑州大学c语言实验报告书答案(补充的部分).docx》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、9.1#includevoidmain(){intm=3,n=5,s=1,k=1,i,l=1;for(n=1;n<=5;n++)s=s*n;for(m=1;m<=3;m++)k=k*m;for(i=1;i<=(5-3);i++)l=l*i;printf("%d",s/k/l);}9.2#include#definen20voidmain(){inta[n],i,FS=0;floatV;a[0]=1,a[1]=1;for(i=2;i2、=0;i#include#definen10voidmain(){doublef(doublex);doubles(doublex,doubley,doubleh);doublea=0,b=3.14159,di,sn=0,r[n+1];inti;di=(b-a)/n;r[0]=a;for(i=1;i<=n;i++)r[i]=r[i-1]+di;for(i=0;i3、)sn=sn+s(f(r[i]),f(r[i+1]),di);printf("%0.3f",sn);}doublef(doublex){doublef;f=sin(2*x)+x;return(f);}doubles(doublex,doubley,doubleh){doubles;s=(x+y)*h/2;return(s);}9.4#includevoidmain(){intjudge(intm);inti=1,k;for(k=99;k>=1;k--){if(judge(k)){printf("%d",k
4、);i++;}if(i==4)break;}}intjudge(intm){inti,re=1;for(i=2;i#includevoidmain(){doublef(doublex);doublef1(doublex);doublea=1.0;do{a=a-f(a)/f1(a);}while(fabs(f(a))>1.0e-5);printf("%f",a);}doublef(doubl
5、ex){doublef;f=x*x*x*x*x+2*x*x*x-x*x+x+1;return(f);}doublef1(doublex){doublef1;f1=5*x*x*x*x+6*x*x-2*x+1;return(f1);}9.6#include#definen1100#definen2200voidmain(){inti,s=0;for(i=n1;i<=n2;i++)if(i)s=s+i;printf("%d",s);}intjudge(intm){inti,re=1;for(i=2;i6、if(m%i==0){re=0;break;}return(re);}9.7递归,程楠不强调(略)11.1#includeintmain(){inta,b,c,*p1,*p2,*p3;voidchange(int*x,int*y);scanf("%d%d%d",&a,&b,&c);p1=&a;p2=&b;p3=&c;if(a>b)change(p1,p2);if(a>c)change(p1,p3);if(b>c)change(p2,p3);printf("%dt%dt%d",*p1,*p2,*p3);
7、return0;}voidchange(int*x,int*y){intp;p=*x,*x=*y,*y=p;}11.2#includeintmain(){floata[20],*p;intn,i;p=a;scanf("%d",&n);for(i=0;iintmain(){inta=2,b=3
8、,*p1,*p2,c;p1=&a,p2=&b;c=*p1,*p1=*p2,*p2=c;printf("%dt%d",a,b);return0;}11.4#include#includeintmain(){chara[36]={'M'