资源描述:
《二级C语言机试题及答案.pdf》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、李苏林编程题#include#includedoublefun(floatt){/**/doubley=0.0;if(t<2)y=3.1*t+2;elseif(t==2)y=3.1;elsey=5*t-8.6;returny;/**/}李苏林voidmain(){floatt;printf("Inputt:");scanf("%f",&t);printf("fun(%.3f)=%.3lf",t,fun(t));getch();}李苏林#include#includedoublef
2、un(floats){/**/doubley=0.0;if(s<30)y=1.36*s;elseif(s>=30&&s<50)y=40.8+1.632*(s-30);elsey=68+2.176*(s-50);returny;/**/}voidmain(){floats;printf("Inputs:");scanf("%f",&s);printf("fun(%.3f)=%.3lf",s,fun(s));getch();}李苏林#include#includeintfun(inta,intb,intc){/**/
3、inty=0;if(a+b>c&&a+c>b&&b+c>a)if((a==b)&&(b!=c)
4、
5、(b==c)&&(b!=a)
6、
7、(a==c)&&(a!=b))y=1;elseif((a*a==b*b+c*c)
8、
9、(b*b==a*a+c*c)
10、
11、(c*c==a*a+b*b))y=2;李苏林returny;/**/}voidmain(){inta,b,c;intans;printf("pleaseinputa,b,c:");scanf("%d%d%d",&a,&b,&c);ans=fun(a,b,c);if(ans==1)printf("Itisa
12、nisoscelestriangle.");elseif(ans==2)printf("Itisanrighttriangle.");elseprintf("Neither.");getch();}李苏林#include#includedoublefun1(floatx){/**/doubley=0.0;if(x<1)y=x;elseif(x>=1&&x<10)y=sqrt(2*x+1);elsey=log(3*x);returny;/**/}李苏林voidmain(){floatx;printf("Inpu
13、tx:");scanf("%f",&x);printf("fun1(%.3f)=%.3lf",x,fun1(x));getch();}#include李苏林#includedoublefun(doublex){/**/doubley;y=(0.16*(pow(x,2)-5.8)*cos(2*x))/(pow(x,2)+1.2+fabs(sin(x)));returny;/**/}voidmain(){printf("fun(2.7)=%7.3lf",fun(2.7));getch();}李苏林#include
14、#includedoublefun(floatt){/**/doubley=0.0;if(t<2)y=3.1*t+2;elseif(t==2)y=3.1;elsey=5*t-8.6;returny;/**/}voidmain()李苏林{floatt;printf("Inputt:");scanf("%f",&t);printf("fun(%.3f)=%.3lf",t,fun(t));getch();}#include#includeintisprime(intn){/**/int
15、i,k,a=1;k=sqrt(n);for(i=2;i<=k;i++)if(n%i==0)a=0;李苏林returna;/**/}voidmain(){inti,k=0;for(i=100;i<=500;i++)if(isprime(i)){printf("%5d",i);k++;if(k%10==0)printf("");}getch();}李苏林#include#includedoublefun(floats){/**/doubley=0.0;if(s<30)y=1.36*s;elseif(s>=30&&s<
16、50)y=40.8+1.632*(s-30);elsey=68+2.176*(s-50);returny;/