《福建省高等学校计算机等级考试二级C语言编程题》由会员分享,可在线阅读,更多相关《福建省高等学校计算机等级考试二级C语言编程题(21页珍藏版)》请在人人文库网上搜索。
1、double fun1(double x) /*/ double f; f=(1+sin(x)+exp(x)/(1+x); return f; /*/ void main() clrscr(); printf(un1 = %n, fun1); printf(un1 = %n, fun1); printf(un1 = %n, fun1); 12打开考生文件夹中的,完成其中的函数fun2(int a ,int n,int b ,int c ),实现: 1)将数组a中大于20的元素依次存放在数组b中; 2)将数组b中的元素按照从小到大的顺序依次存放到数组c中; 3)函数返回数组b中的元素个数。 #i。
2、nclude #include int fun2(int a,int n,int b,int c) /*/ int nb=0; int i,j=0,temp; for(i=0;i-20) bj=ai;nb+;j+; for(i=0;icj+1) temp=cj; cj=cj+1; cj+1=temp; return nb; /*/ void main() int n = 10, i, nb; int aa10 = 12, -10, -31, -18, -15, 50, 17, 15, -20, 20; int bb10, cc10; clrscr(); printf(There are - e。
3、lements in aa.n, n); printf(They are: ); for(i=0; i #include #include #include 0) strcpy(temp,a);strcpy(a,b); strcpy(b,temp); if(strcmp(a,c)0) strcpy(temp,a);strcpy(a,c); strcpy(c,temp); if(strcmp(b,c)0) strcpy(temp,b);strcpy(b,c); strcpy(c,temp); /*/ void main() char str115=Fuzhou,str215=Fujian,str。
4、315=China; clrscr(); fun2(str1,str2,str3); printf(The ordered strings is : %s, %s, %sn,str1,str2,str3); getch(); 31打开完成其中的函数fun1,该函数的数学表达式是: 当x3时 例如: fun1= fun1= fun1= #include double fun1(double x) /*/ double f; if(x int fun(char *s) /*/ int i,n=0; for(i=0 ; si!=0;i+) if(si= ) n+; return n; /*/ voi。
5、d main() char str255; gets(str); printf(%dn,fun(str); 41打开程序,完成其中的f( )函数,使其计算: 如 输入:12 输出:f= 输入: 输出:f= 输入: 输出:f= #include double f(float x) /*/ double f; if(x #include #include #include #include #include float fun(float a,char flag,float b) /*/ float f; switch(flag) case +: f=a+b; break; case -: f=a。
6、-b; break; case *: f=a*b; break; case /: f=a/b; break; return f; /*/ void main() float a,b; printf(Please input two numbers:n); scanf(%f%f,&a,&b); printf(%.2f+%.2f=%.2fn,a,b,fun(a,+,b); printf(%.2f-%.2f=%.2fn,a,b,fun(a,-,b); printf(%.2f*%.2f=%.2fn,a,b,fun(a,*,b); printf(%.2f/%.2f=%.2fn,a,b,fun(a,/,b); getch();。