以下程序是选出能被3整除且至少有一位是5的两位数,打印出所有的这样的数及其个数。请选择填空。sub(int k,int n){int a1,a2;a2=【1】;a1=k-【2】;if((k%3==0&&a2==5)||(k%3==0&&a1==5)){printf("%4d",k);n++;return n;}else return -1;}main(){int n=0,k,m;for(k=10;k<100;k++){m=sub(k,n);if(m!=-1) n=m;}printf("\nn=%d",n);}
查看答案
以下程序的功能是根据输入的"y"("Y")与"n"("N"),在屏幕上分别显示出"This is YES."与"This is NO."。请填空。#includevoid YesNo(char ch){switch(ch){case 'y':case 'Y':printf("\nThis is YES.\n");【1】;case 'n':case 'N':printf("\nThis is NO.\n");}}main(){char ch;printf("\nEnter a char 'y','Y' or 'n','N':");ch=【2】;printf("ch:%c",ch);YesNo(ch);}
以下Check函数的功能是对value中的值进行四舍五入计算,若计算后的值与ponse值相等,则显示"WELL DONE!!",否则显示计算后的值。已有函数调用语句Check(ponse,value);请填空。void Check(int ponse,float value){int val;val=【1】;printf("计算后的值:%d",val);if(【2】) printf("\nWELL DONE!!!\n");else printf("\nSorry the correct answer is %d\n",val);}
以下程序的运行结果是输出如下图形。请填空。*************************#include void a(int i){int j,k;for(j=0;j<=7-i;j++) printf(" ");for(k=0;k<【1】;k++) printf("*");printf("\n");}main(){int i;for(i=0;i<3;i++) 【2】;for(i=3;i>=0;i--) 【3】;}
下面函数pi的功能是:根据以下公式,返回满足精度(0.0005)要求的π值,请填空。π/2=1+1/3+1/3*2/5+1/3*2/5*3/7+1/3*2/5*3/7*4/9+…#include #include#includedouble pi(double eps){double s,t;int n;for(【1】;t>eps;n++){s+=t;t=n*t/(2*n+1);}return (【2】);}main(){double x;printf("\nPlease enter a precision:");scanf("%lf",&x);printf("\neps=%lf,π=%lf",x,pi(x));}