1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 安徽省二级C语言机考题库 计算机等级考试二级C语言机考题库

安徽省二级C语言机考题库 计算机等级考试二级C语言机考题库

时间:2018-12-27 22:54:30

相关推荐

安徽省二级C语言机考题库 计算机等级考试二级C语言机考题库

给定程序中,函数fun的功能是:将形参n所指变量中,各位上为偶数的数去除,剩余的数按原来从高位到低位的顺序组成一个新的数,并通过形参指针n传回所指变量。例如,输入一个数:27638496,新的数为:739

void fun(unsigned long *n)

{ unsigned long x=0, i; int t;

i=1;

while(*n)

/**********found**********/

{ t=*n % __1__;

/**********found**********/

if(t%2!= __2__)

{ x=x+t*i; i=i*10; }

*n =*n /10;

}

/**********found**********/

*n=__3__;

}

答案:(1)10 (2)0

(3)x

2.改错题

给定程序MODI1.C中函数fun的功能是:计算n!。例如,给n输入5则输出120.000000。

double fun ( int n )

{ double result = 1.0 ;

/************found************/ if n = = 0

return 1.0 ;

while( n >1 && n < 170 )

/************found************/ result *= n--

return result ;

}

答案:(1)if (n == 0)

n--;

3.编程题

请编写一个函数fun,它的功能是:

例如,若输入字符串“-1234”,则函数把它转换为整数数值-1234。

long fun ( char *p)

{ int i, len, t; /* len为串长,t为正负标识*/

long x=0;

len=strlen(p);

if(p[0]=='-')

{ t=-1; len--; p++; }

else t=1;

/* 以下完成数字字符串转换为一个数字*/

while(*p) x = x*10-48+(*p++); return x*t;

给定程序中,函数fun的功能是将形参给定的字符串、整数、浮点数写到文本文件中,再用字符方式从此文本文件中逐个读入并显示在终端屏幕上。

void fun(char *s, int a, double f) {/**********found**********/

__1__ fp;

char ch;

fp = fopen("file1.txt", "w");

fprintf(fp, "%s %d %f\n", s, a, f); fclose(fp);

fp = fopen("file1.txt", "r");

printf("\nThe result :\n\n");

ch = fgetc(fp);

/**********found**********/ while (!feof(__2__)) {

/**********found**********/

putchar(__3__); ch

fgetc(fp); }

putchar('\n');

fclose(fp);

}

答案:(1)FILE * (2)fp

(3)ch

2.改错题

给定程序MODI1.C中函数fun 的功能是:依次取出字符串中所有数字字符,形成的字符串,

void fun(char *s)

{ int i,j;

for(i=0,j=0; s[i]!='\0'; i++)

if(s[i]>='0' && s[i]<='9')

/**********found**********/

s[j]=s[i];

/**********found**********/

s[j]="\0";

}

答案:(1)s[j++]=s[i]; (2)s[j]='\0'; 3.编程题

fun

W

S

H

中的内容应该是:

s[][N], char *b)

/*

*/

姓名和3

fun

*filename, STU n)

(2)fp

MODI1.C中的函

n, int m)

*h=NULL, *p, *s;

p;

h;

fun,

*s)

姓名和3

fun

所指的文件中,

*filename)

int i, j;

= s[i]; s[i] = s[j]; s[j]

sizeof(STU), N, fp);

*/

(2)> (3)fwrite

中函数fun的功

n个

并且覆盖原串。

79。

char s[], int n )

a[80] , *p;

a[i]='*';

(2)while(*p++);

fun

N

0至9

d[0]中,把10至

d[1]中,把

d[2]

100岁(含100岁

d[10]

*a, int *b)

10) b[M - 1]++ ;

fun

*s, int a, double f)

double f1;

%d

str,

(2)fclose(fp)

中函数fun

m(m≤10)

a[], int m)

b[i]=a[i];

if(b[i].s > b[j].s) j=i;

t(k)=b(j);

b[j].s=0;

t;

fun

a[], int n)

fun

X1=5.000000

i, double x,

__3__(x, y);

(2)f1

中函数fun

char *t)

char *ss, *tt;

tt=t;

return t;

return s;

char *t)

(3)tt++;

fun

到第m个字符,

m+1

有的内容为

,m的值为3,

符串中的内容应该是

*w, int m) /*

*/

___1___)

%s %c

tt.birthday.year,

(2)tt.score[i] (3)std

1.C中函数fun的功

a[0]中的数对调、

a[1]中的数对调。

* a, int n )

(2)if(a[k]>a[m]) m=k;

一个函数unsigned

w),w是一个大于10的

w是n(n≥2)位的整

w的低n-1位的数作为

w值为5923,则

;w值为923则函数返

fun ( unsigned w )

3门课的成绩。函数fun

a。

*ss,float a)

original number and

a number : ");

result of

(2)score[i]

中函数fun的功

所求阶乘的值作为

k=10,则应

k)

(k > 0) (2)else if

n×n的二维数组,并在

自动赋值。请编写函数

,函数的功能是:

n。

的值为3,a数组中的值

a数组中的

9 8

第 1 页共16 页

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。