福建省计算机二级考试C语言上机题库改错填空编程

发布时间 : 星期六 文章福建省计算机二级考试C语言上机题库改错填空编程更新完毕开始阅读

11 12 13 14 15 20 19 18 17 16 21 22 23 24 25 #include #include #define M 10

void pnt(int a[M][M],int n) {int i,/**/ /**/; for(i=0;i

a[i][j]=/**/ /**/; else

a[i][j]=i*n+n-j; }

printf(\ for(i=0;i

printf(\ printf(\ } }

void main() {

int a[M][M]; int n;

printf(\n(2<=n And n<=10):\

scanf(\

pnt(/**/ /**/,n); getch(); }

Ccon231.c

程序ccon231.c, 计算以下分数序列的前18项之和

21,32,53,85,138,??

#include void main() {

??5x?500fun(x)???0.01500?x?2000?0.008(x?2000)2000?x?5000??4444x?5000 int i;

float sum,a=2,b=1,t; /**/ /**/; for (i=1;i<=18;i++) {

sum+=/**/ /**/; t=a; a=a+b;

b=/**/ /**/; }

printf(\ getch(); }

Ccon232.c

程序ccon232.c中的inv函数,通过指针变量将字符串str的内容”asdfjk”,调用inv函数后,变成:”kjfdsa”。 #include #include void inv(char *str) {int i,j,k;

j=/**/ /**/; for(i=0;i

*(str+i)=*(str+j);

*(str+j)=/**/ /**/; } }

void main( ) {

char str[]=\

printf(\ inv(str);

printf(\ getch(); }

四、编程题 cprog191.c

打开程序cprog191.c,完成其中的fun函数:根据输入的汇款数额,求应交的汇费。设应交汇费的计算公式如下:

#include #include double fun(float x) { /**/

/**/ }

void main() {

float x; double y; clrscr();

printf(\ scanf(\ y = fun(x);

printf(\ getch(); }

cprog192.c

打开程序cprog192.c,完成其中的fun函数:对4×4矩阵从顶行开始各行按从左到右顺序查找,找出各行中0元素之后的所有负数,并按元素出现的先后顺序存放到数组b中,并返回这些负数之和。如矩阵为:

???20?3?1???8204???03?3?12???210?133??则调用函数fun( )后,数组b各元素依次为-3,-1,-4,-3,-12,-13,并返回-36.

#include #include #define ROW 4 #define COL 4 #define LEN 12

int fun(int a[][COL],int b[]) { /**/

/**/ }

void main( ) { int

arra[ROW][COL]={{-2,0,-3,-1},{-8,2,0,-4},

{0,3,-3,-12},{21,0,-13,3}}; int arrb[LEN],i,result; for(i=0;i

result=fun(arra,arrb); printf(\ for(i=0;i

if(arrb[i]==0) printf(\ else printf(\ printf(\ getch( ); }

cprog201.c

打开cprog201.c,完成其中的函数fun,该函数的数学表达式是

?1/(1?e?x)x?10fun(x)?????(x?3)sin(2x)x?10#include #include double fun(float x) { /**/

/**/ }

void main( ) {

float x; double y;

printf(\ scanf(\ y = fun(x);

printf(\ getch(); }

cprog202.c

打开程序cprog202.c,完成其中的fun函数:

函数fun(double x, int n),用以下公式近似计算cos(x)的值:

x2x42ncos(x)?1?2!?4!?x66!???(?1)nx(2n)!

#include

void main() {

double x; int n;

double fun(double x,int n); printf(\ scanf(\

printf(\ getch(); }

double fun(double x,int n) {

/**/

/**/ }

cprog211.c

打开cprog211.c,完成其中的函数fun,该函数的数学表达式是

?ln(3x)x?10fun(x)???2x?11?x?10??xx?1

#include #include double fun(float x) { /**/

/**/ }

void main( ) {

float x; double y; clrscr();

printf(\ scanf(\ y = fun(x);

printf(\ getch( ); }

cprog212.c

打开程序cprog212.c,完成其中的fun函数:对两个字符串中小写英文字母的个数进行比较,并返回比较的结果。(注:第1个字符串比第2个字符串的小写英文字母个数多,则返回正数,相等返回0,个数少则返回负数)

例如:字符串str1为“abc123”,字符串str2为”abcd”,则函数fun的返回值应小于0。 #include

int fun(char *str1, char *str2) { /**/

联系合同范文客服:xxxxx#qq.com(#替换为@)