资源描述:
《浙江大学c程序设计 答案二》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、20021程序填空,不要改变与输入输出有关的语句。输入一个正整数repeat(0intmain(void){intrepeat,ri;doublex,y;scanf("%d",
2、&repeat);for(ri=1;ri<=repeat;ri++){scanf("%lf",&x);/*---------*/if(x!=0)y=1/x;elsey=0;printf("f(%.2f)=%.1f",x,y);}}20022程序填空,不要改变与输入输出有关的语句。输入华氏温度,输出对应的摄氏温度。计算公式:c=5*(f-32)/9,式中:c表示摄氏温度,f表示华氏温度。输入输出示例:括号内为说明输入150(fahr=150)输出celsius=65#includeintmain
3、(void){intcelsius,fahr;/*---------*/scanf(“%d”,&fahr);celsius=5.0*(fahr-32)/9;printf("celsius=%d",celsius);}beconsistentwithinthesamedisk.Alternateunifiedcorerequirementsplacedontheterminalstripterminals,onlineidentityandensurethecoppercoreisnotexposed.6.4.6
4、enclosurewithinthesametothecablecoreprovidesbindingintoacircle,harnesstiespacingisgenerally100mm;branchofficesshallbebindingonbothends,eachcore20023程序填空,不要改变与输入输出有关的语句。输入存款金额money、存期year和年利率rate,根据下列公式计算存款到期时的利息interest(税前),输出时保留2位小数。interest=money(1+rate)^yea
5、r-money输入输出示例:括号内为说明输入100030.025(money=1000,year=3,rate=0.025)输出interest=76.89#include#includeintmain(void){intmoney,year;doubleinterest,rate;/*---------*/scanf(“%d%d%lf”,&money,&year,&rate);interest=money*pow((1+rate),year)-money;printf("inte
6、rest=%.2f",interest);}20024程序填空,不要改变与输入输出有关的语句。输入一个正整数repeat(0=0时,f(x)=x^0.5,当x小于0时,f(x)=(x+1)^2+2x+1/x。输入输出示例:括号内是说明输入3(repeat=3)10-0.50输出f(10.00)=3.16f(-0.50)=-2.75f(0.00)=0.
7、00#include#includeintmain(void){intrepeat,ri;doublex,y;scanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){/*---------*/beconsistentwithinthesamedisk.Alternateunifiedcorerequirementsplacedontheterminalstripterminals,onlineidentityandensurethecopperc
8、oreisnotexposed.6.4.6enclosurewithinthesametothecablecoreprovidesbindingintoacircle,harnesstiespacingisgenerally100mm;branchofficesshallbebindingonbothends,eachcorescanf("%lf",&x);