资源描述:
《c语言模拟 改错填空编程题》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、一.1.#include#includevoidmain(){floata[3],s,area;inti;printf("Pleaseinput3numbers:");for(i=0;i<3;i++)scanf("%f",/**/a[i]/**/);/**/if(a[0]+a[1]>a[2]
2、
3、a[1]+a[2]>a[0]
4、
5、a[0]+a[2]>a[1])/**/{s=(a[0]+a[1]+a[2])/2;area=sqrt(s*(s-a[0])*(s-a[1])*(s-a[2]));printf("areais%.2f",a
6、rea);}elseprintf("error.");getch();}2.#include#include/**/voidfun()/**/{intlarge,middle,small,n=0;clrscr();for(large=0;large<=33;large++)for(middle=0;middle<=50;middle++){small=2*(100-3*large-2*middle);/**/if(large+middle+small=100)/**/{n++;printf("%d-->large:%d,midd
7、le:%d,small:%d",n,large,middle,small);}}returnn;}voidmain(){intnum;num=fun();printf("Thereare%dsolutions.",num);getch();}填空题1.#include#includemain(){inti,/**//**/;inta[4][4],sum;sum=/**//**/;printf("Pleaseinput16numbers:");for(i=0;i<4;i++)for(j=0;j<4;j++)scanf("
8、%d",&a[i][j]);for(i=0;i<4;i++)/**//**/printf("%d",sum);getch();}2.#includeintfun(inta[],intn,/**//**/){intleft,right,mid;left=0;right=n-1;while(left<=right){mid=/**//**/;if(qa[mid])left=mid+1;elsereturnmid;}return-1;}main(){inta[]={3,4,6,11,17,22,
9、31,45};intk,n;n=sizeof(a)/sizeof(int);k=fun(a,n,31);printf("%d",k);getch();}3.#include#includeintfun(/**//**/,floatx,floaty){intbIn;bIn=/**//**/0):");scanf("%f",&r);}printf("Pleaseinpu
10、tthedot(x,y):");scanf("%f%f",&x,&y);bIn=fun(r,x,y);if(bIn==1)printf("inthecircle!");elseprintf("outoftheCircle!");getch();}1.#include#includedoublef(floatx){/**//**/}voidmain(){floatx;doubley;printf("Pleaseinputanumber:");scanf("%f",&x);y=f(x);printf("f(%.3f)=%.
11、3f",x,y);getch();}2.#include#includevoidf(charp[][20],intn);voidmain(){inti;charp[][20]={"abc","xabdfg","abbd","dcdbe","cd"};f(p,5);clrscr();for(i=0;i<5;i++)printf("%s",p[i]);getch();}voidf(charp[][20],intn){/**//**/}二1.#include#include