首页 > 计算机类考试
题目内容 (请给出正确答案)
[单选题]

有以下函数,该函数的功能是()int fun(char *s){char *t=s;while(*t++);return(t-s);}

A.比较两个字符的大小

B.计算s所指字符串占用内存字节的个数

C.计算s所指字符串的长度

D.将s所指字符串复制到字符串t中

答案
收藏

B、计算s所指字符串占用内存字节的个数

如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“有以下函数,该函数的功能是()int fun(char *s…”相关的问题
第1题
请编写函数fun(),该函数的功能是:计算并输出 S=1+(1+20.5)+(1+20.5+30.5)+…+(1+20.5+30.5+…+n0.5

请编写函数fun(),该函数的功能是:计算并输出

S=1+(1+20.5)+(1+20.5+30.5)+…+(1+20.5+30.5+…+n0.5)

例如,若主函数从键盘给n输入20后,则输出为

s=534.188884。

注意;部分源程序给出如下。

请勿改动主函数main 和其他函数中的任何内容,仅在函数fun 的花括号中填入所编写的若干语句。

试题程序:

include <math. h>

include <stdio. h>

double fun(int n)

{

}

main()

{

int n;

double s;

printf("\n\nInput n: ");

scanf ("%d", &n);

s=fun (n)

printf ("\n\ns=%f\n\n", s);

}

点击查看答案
第2题
设有以下函数 f(int a) { int b=0; static int c=3; b++;c++; return(a+b+c); } 如果在下面的程

设有以下函数 f(int a) { int b=0; static int c=3; b++;c++; return(a+b+c); } 如果在下面的程序中调用该函数,则输出结果是______。 main() { int a=2,i; for(i=0;i<3;i++)printf("%d\n"f(a)); }

A.7 8 9

B.7 9 11

C.7 10 13

D.7 7 7

点击查看答案
第3题
以下程序中函数 f 的功能是在数组 x 的 n 个数 (假定 n 个数互不相同 ) 中找出最大最小数

以下程序中函数 f 的功能是在数组 x 的 n 个数 (假定 n 个数互不相同 ) 中找出最大最小数 , 将其中最小

的数与第一个数对换 , 把最大的数与最后一个数对换 . 请填空 .

#include <stdio.h>

viod f(int x[],int n)

{ int p0,p1,i,j,t,m;

i=j=x[0]; p0=p1=0;

for(m=0;m<n;m++)

{ if(x[m]>i) {i=x[m]; p0=m;}

else if(x[m]<j) {j=x[m]; p1=m;}

}

t=x[p0]; x[p0]=x[n-1]; x[n-1]=t;

t=x[p1]; x[p1]= _[14]_______ ; _[15]_______ =t;

}

main()

{ int a[10],u;

for(u=0;u<10;u++) scanf("%d",&a[u]);

f(a,10);

for(u=0;u<10;u++) printf("%d",a[u]);

printf("\n");

}

点击查看答案
第4题
f()函数是类的一个常成员函数,它有一个int型参数,并且返回类型为int。下列对该常成员函数进行声明的选项中,正确的是

A.int f(int)const

B.onst int f(int)

C.int f(const int)

D.onst int f(const int)

点击查看答案
第5题
请编写函数fun,该函数的功能是:将两个两位数的正整数a、b合并形成一个整数放在c中。合并方式是:将a
数的十位和个位数依次放在c数的干位和十位上,b数的十位和个位数依次放在c数的个位和百位上。例如:当a=32,b=78。调用该函数后,c=3827。 include <conio.h> include <Stdio.h> void fun(int a,int b,(1) ) { (2); } main() { int a,b;long c; clrscr(); printf("Input a,b:"); scanf("%d%d",&a,&b); fun(a,b,&c); printf("The result is:%ld\n",c); NONO();/*本函数与考生答题无关,考生不得改动,否则后果自负。*/ }

点击查看答案
第6题
下列程序定义了N×N的二维数组,并在主函数中自动赋值;请编写函数fun(int a[][N]),该函数的功能是:

下列程序定义了N×N的二维数组,并在主函数中自动赋值;请编写函数fun(int a[][N]),该函数的功能是:使数组左下半三角元素中的值全部置成0。例如a数组中的值为

a=1 9 7

2 3 8

4 5 6

则返回主程序后a数组中的值应为

0 9 7

0 0 8

0 0 0

注意:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。

试题程序:

include <conio.h>

include <stdio.h>

include <stdlib.h>

define N 5

int fun (int a[] [N])

{

}

main()

{

int a[N] [N],i,j;

clrscr();

printf("*****The array*****\n");

for(i=0;i<N;i++)

/*产生—个随机的5*5矩阵*/

{ for(j=0;j<N;j++)

{a[i][j]=rand()%10;

printf("%4d", a[i][j]);

}

printf("\n");

}

fun (a);

printf("THE RESULT\n");

for(i=0;i<N;i++)

{ for(j=0;j<N;j++)

printf("%4d",a[i][j));

printf("\n");

}

}

点击查看答案
第7题
请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的

请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的字符重新保存在字符串e口中。字符串sb从键盘输入,其长度作为参数传入函数fun()。

例如,输入“abcdefghijkl”,输出“cdfhl”。

注意:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。

试题程序:

include <stdio.h>

define N 80

void fun(char s[],int n)

{

int i, j, k, flag;

【 】;

for(i=0; i<n; i++)

{

if (i>1)

s [k++] =s [i];

flag=I;

for(【 】; j<i&&flag; j++)

if (i%j==0)

{

flag=0;

【 】

}

}

s [k]='\0';

}

main()

{

int i=0, strlen=0;

char str[N];

clrscr ();

printf("\n Input a string:\n");

gets (str);

while (str [i] !='\0')

{

strlen++;

i++;

}

fun (str, strlen);

printf("\n*** display string ***\n");

puts (str);

}

点击查看答案
第8题
若有int f(int a,int b);, 则说明函数f()。

A.是一个内部函数

B.是一个外部函数

C.只能在本文件中使用

D.不能被同一源程序其他本文件中的函数调用

点击查看答案
第9题
有以下函数定义:void fun(int n double x){…}若以下选项中的变量都已正确定义并赋值,则对函数fun

有以下函数定义: void fun(int n double x){…} 若以下选项中的变量都已正确定义并赋值,则对函数fun的正确调用语句是()。

A.fun(int y,double m);

B.k=fun(10,12.5);

C.fun(x,n);

D.void fun(n,x);

点击查看答案
第10题
请编写函数fun(),该函数的功能是:移动字符串中的内容,移动的规则是把第1到第m个字符,平移到字符

请编写函数fun(),该函数的功能是:移动字符串中的内容,移动的规则是把第1到第m个字符,平移到字符串的最后,把第m+1到最后的字符移到字符串的前部。

例如,字符串中原有的内容为ABCDEFGHIJK,m的值为 3,移动后,字符串中的内容应该是DEFGHIJKABC。

注意:部分源程序给出如下。

请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。

试题程序:

include <stdio. h>

include <string.h>

define N 80

void fun (char *w, int m)

{

}

main ()

{

char a[N]= "ABCDEFGHIJK";

int m;

printf ("The origina string : \n");

puts (a);

printf("\n\nEnter m: ");

scanf ("%d", &m);

fun (a, m);

printf (" \nThe string after moving : \n");

puts (a);

printf ("\n\n");

}

点击查看答案
第11题
下面哪几个函数是public void example(){...}的重载函数()。A. public void example(int m){.

下面哪几个函数是public void example(){...}的重载函数()。

A. public void example(int m){...}

B. public int example(){...}

C. public void example2(){...}

D. public int example3 (int m, float f){...}

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改