首页 > 公务员
题目内容 (请给出正确答案)
[主观题]

有以下程序#include<stdio.h>int f(int m){static int n=0; n+=m: return n;}main(){ int

有以下程序

#include<stdio.h>

int f(int m)

{ static int n=0;

n+=m:

return n;

}

main()

{ int n=0;

printf("%d,",f(n));

printf("%d\n",f(n++));

}

程序运行后的输出结果是

A.1,2

B.1,1

C.2,3

D.3,3

答案
收藏

A
解析:static变量用于局部变量中有记忆功能和全局生存期。函数中的静态变量的特点是每次调用函数,静态变量的值是上次调用完该函数后的静态变量值,所以在此题中,第一调用函数,返回1,此时函数中的静态变量n的值为l,所以第二次调用函数时,返回值为2。

如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“有以下程序#include<stdio.h>int f(in…”相关的问题
第1题
(21 )有以下程序# include (stdio.h >main (){ int a = l ; b = 2 ;for (; a < 8 ; a++ ) { b

(21 )有以下程序

# include (stdio.h >

main ()

{ int a = l ; b = 2 ;

for (; a < 8 ; a++ ) { b+=a ; a+=2 ; }

printf (" %d , %d \ n ", a , b ) ;

}

程序运行后的输出结果是

A ) 9 , 18

B ) 8 , 11

C ) 7 , 11

D ) 10 , 14

点击查看答案
第2题
‎有以下程序‎#include‎void main()‎{ int a,b,d=25;‏a=d/10%9;‏b=a&&(-1);‏printf("%d,%d/n",a,b);}‎程序运行后的输出结果是()。

A.2,1

B.2,0

C.3,1

D.6,1

点击查看答案
第3题
有以下程序#include<stdio.h>#define S(x)4*(x)*x+1main(){int k=5,j=2; printf(“%d\n”,S(

有以下程序

#include<stdio.h>

#define S(x)4*(x)*x+1

main()

{int k=5,j=2;

printf(“%d\n”,S(k+j));

}

程序运行后的输出结果是

A.197

B.143

C.33

D.28

点击查看答案
第4题
有以下程序:#include<stdio.h>void fun(char *a,char*B){while(*a=='*')a++;while(*b=*A){b++;a+

有以下程序: #include<stdio.h> void fun(char *a,char*B){while(*a=='*')a++; while(*b=*A){b++;a++;} } main() {char*s="****a*b****",t[80]; fun(s,t);puts(t); } 程序的运行结果是()。

A.*****a*b

B.a*b

C.a*b****

D.ab

点击查看答案
第5题
有以下程序#include<stdio.h>#include<string.h>main(){char x[]=“STRING”;x[0]=0;x[1]=’\0’;x[2]=’0’;printf(”%d%d\n”,sizeof(x),strlen(x));}程序运行后的输出结果是()。

A.6 1

B.7 0

C.6 3

D.7 1

点击查看答案
第6题
‎有以下程序‎#include‎void main()‎{int a ;‎scanf("%d",&a);‎if(a >= 0)‎{if

A.-11 is a positive odd number.

B.-11 is a negative odd number.

C.-11 is a positive even number.

D.11 is a negative even number.

点击查看答案
第7题
38) 有以下程序:#include <stdio.h>void fun(char *t,char *s){ while(*t!=0) t++;while((

38) 有以下程序:

#include <stdio.h>

void fun(char *t,char *s)

{ while(*t!=0) t++;

while((*t++=*s++)!=0);

}

main()

{ char ss[10]= " acc " ,aa[10]= " bbxxyy " ;

fun(ss,aa);

printf(" %s,%s\n " ,ss,aa);

}

程序运行结果是

A)accxyy,bbxxyy

B)acc, bbxxyy

C)accxxyy,bbxxyy

D) accbbxxyy,bbxxyy

点击查看答案
第8题
‌有以下程序#include‎void main()‎{int a = 12, b = -34, c = -56, min;‎min = a;if(min > b)‎min = b;‎if(min > c)‎min = c;‎printf("min = %d", min);}输出结果是()。

A.min = 12

B.min = -34

C.-56

D.min = -56

点击查看答案
第9题
‏有以下程序‏#include‏void main()‏{int i,s=0;for(i=1;i<10;i+=2)‎s+=i+1;‎printf("%d/n",s);}‏程序运行后的输出结果是()。

A.数1~10的累加和

B.数1~9的累加和

C.数1~9中的奇数之和

D.数1~10中的偶数之和

点击查看答案
第10题
以下程序的输出结果是_______。#include<stdio.h>main(){ int i;for(i=1;i<5;i++){ if(i%2)printf

以下程序的输出结果是_______。 #include<stdio.h> main() { int i; for(i=1;i<5;i++){ if(i%2)printf("*"); else continue; printf("#"); } printf("$\n"); }

A.*#*#*#$

B.#*#*#*$

C.*#*#$

D.#*#*$

点击查看答案
第11题
在编写红外数据接受程序时,需要调用红外类库的头文件,以下调用该头文件的程序正确的是?()

A.#includeIRremote.h

B.#includeIRremote

C.#include

D.#include‘IRremote.h’

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