1、82711/*-【程序填空】-功能:已知 X、Y 、Z 分别表示 09 中不同的数字,编程求出使算式XXXX+YYYY+ZZZZ=YXXXZ 成立时X、Y、Z 的值,并要求打印该算式。-*/#include #include int main()int x,y,z;/*SPACE*/for(x=0;【?】;x+)for(y=0;yint binarySearch(int a,int n,int key)int low,high,mid;low=0;high=n-1;/*SPACE*/while(【? 】)/下面开始循环寻找查找范围,即寻找最小和最大下标mid=(low+high)/2;if(k
2、eyamid) /*SPACE*/【?】 ;else /*SPACE*/【? 】;return -1;int main()82712int a10=1,2,3,4,5,6,7,8,9,10;int b,c;b=4;c=binarySearch(a,10,b);if(c=1) printf(“not found“);else printf(“position %dn“,c);return 0;/*- 【程序改错】-功能:计算数组元素中值为正数的平均值(不包括 0)。例如:数组中元素的值依次为 39,-47, 21, 2,-8,15,0,则程序的运行结果为 19.250000。-*/#includ
3、e double fun(int s)/*FOUND*/int sum=0.0;int c=0,i=0;/*FOUND*/while(si =0)if (si0)sum+=si;c+;i+;/*FOUND*/sum=c;/*FOUND*/return c;main()int x1000;int i=0;doscanf(“%d“,while(xi+!=0);printf(“%fn“,fun(x);/*- 【程序改错】-功能:为一维数组输入 10 个整数,然后将其中最小的数与第一个数对换,将最大的数与最后一个数对换,最后输出数组元素。-*/#include main()int a10;void i
4、nput(int *arr,int n);void output(int *arr,int n);void max_min(int *arr,int n);input(a,10);max_min(a,10);output(a,10);void input(int *arr,int n) int *p,i;p=arr;printf(“please enter 10 integers:n“);for(i=0;ivoid wwjt(); float fun(float x)/*Program*/* End */int main() float x,f;printf(“input x=“);scanf
5、(“%f“,f=fun(x);printf(“x=%f,f(x)=%fn“,x,f);wwjt();return 0;void wwjt()FILE *IN,*OUT;int n;float i;float o;IN=fopen(“in.dat“,“r“);if(IN=NULL)printf(“Read FILE Error“);OUT=fopen(“out.dat“,“w“);if(OUT=NULL)printf(“Write FILE Error“);82714for(n=0;nvoid wwjt();int fun(int n)/*Program*/* End */void main()
6、int k;k=fun(1234);printf(“k=%dn“,k);wwjt();void wwjt()FILE *IN,*OUT;int iIN,iOUT,i;IN=fopen(“22.IN“,“r“);if(IN=NULL)printf(“Please Verify The Currernt Dirit May Be Changed“);OUT=fopen(“22.out“,“w“);if(OUT=NULL)printf(“Please Verify The Current Dir it May Be Changed“);for(i=0;i10;i+)fscanf(IN,“%d“,iOUT=fun(iIN);fprintf(OUT,“%dn“,iOUT);fclose(IN);fclose(OUT);