2、stido.h>voidnum(){externintx,y;inta=15,b=10;x=a-b;y=a+b;}intx,y;main(){inta=7,b=5;x=a+b;y=a-b;num();printf(“%d,%d”,x,y);}3.以下程序的運行結(jié)果是.main(){inta=2,I;for(I=0;I<3;I++)printf(“4%d”,f(a));}f(inta){intb=0;staticintc=3;b++;c++;return(a+b+c);}4.以下程序的功能是根據(jù)輸入的“y”(“Y”)與“n”(“N”),在屏幕上
3、分別顯示出“ThisisYES.”與“ThisisNO.”。請?zhí)羁铡?includevoidYesNo(charch){switch(ch){case’y’:case’Y’:printf(“ThisisYES.”);break;case’n’:case’N’:printf(“ThisisNO.”)}}main(){charch;printf(“Enterachar‘y’,’Y’,or’n’,’N’);ch=___________________;printf(“ch:%c”,ch);YesNo(ch);}5.
4、以下Check函數(shù)的功能是對value中的值進行四舍五入計算,若計算后的值與ponse值相等,則顯示“WELLDONE??!”,否則顯示計算后的值。已有函數(shù)調(diào)用語句Check(ponse,value);請?zhí)羁?。VoidCheck(intponse,floatvalue){intval;val=_______________________________;printf(“計算后的值:%d”,val);if(_____________________)printf(“WELLDONE!!!”);elseprintf(“Sorrytheco
5、rrectis%d”,val);}6.若輸入一個整數(shù)10,以下程序的運行結(jié)果是【】。main(){inta,e[10],c,i=0;printf(“輸入一整數(shù)”);scanf(“%d”,&a);while(a!=0){c=sub(a);a=a/2;e[i]=c;i++}for(;i>0;i--)printf(“%d”,e[i-1]);}sub(inta){intc;c=a%2;returnc;}7.函數(shù)gongyu的作用是求整數(shù)num1和num2的最大公約數(shù),并返回該值,請?zhí)羁誫ongyu(intnum1,intnum2){inttemp
6、,a,b;if(num1______num2){temp=num1;num1=num2;num2=temp;}a=num1;b=num2;while(_________){temp=a%b;a=b;b=temp;}return(a);}8.下面函數(shù)pi的功能是:根據(jù)以下攻勢,返回滿足精度(0.0005)要求的pi的值pi1121231234─=1+─+──+───+────+···23353573579#include#include#includedoublepi(doubleeps)-140
7、-{doubles,t;intn;for(_____________;t>eps;n++){s+=t;t=n*t/(2*n+1);}return(__________);}main(){doublex;printf(“Pleaseenteraprecision:”);scanf(“%lf”,&x);printf(“eps=%lf,pi=%lf”,x,pi(x));}9.以下程序的運行結(jié)果是【】.#includemain(){printf("FACT(5):%d",fact(5));printf("FACT(1):%d
8、",fact(1));fact(-5);}fact(intvalue){if(value<0){printf("FACT(<0):E