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

有以下程序#include<stdio.h>int fun(){static int x=1;x+=1;return x;}main(){int i,s=

有以下程序

#include<stdio.h>

int fun()

{static int x=1;

x+=1;return x;

}

main()

{int i,s=1;

for(i=1;i<=s;i++)s+=fun();

printf(”%d\n”,s);

}

程序运行后的输出结果是()。

A.11

B.21

C.6

D.120

答案
收藏

B
解析:本题考查静态变量,C语言中静态变量的生存期是从程序的开始到结束。本题中静态变量x,随着每次进入循环不断增长5次,返回的值分别为2、3、4、5、6。所以s=1+2+3+4+5+6=21。所以选B。

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

有以下程序: #include <stdio. h> main () { char a :'a',b; printf("% c," , + + a); printf("%c \n" ,b =a++); }程序运行后的输出结果是()。

A.b,b

B.b,c

C.a,b

D.a,c

点击查看答案
第2题
有以下程序: #include < stdio. h > main () int a=3,b=4,c=5,d=2;if(a>b) if(b>c)printf("%d",

有以下程序: #include < stdio. h > main () int a=3,b=4,c=5,d=2; if(a>b) if(b>c)printf("%d",d++ +1); else printf("% d", + + d + 1 ); printf("% d \n" ,d); 程序运行后的输出结果是()。

A.2

B.3

C.43

D.44

点击查看答案
第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题
(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

点击查看答案
第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题
‎有以下程序‎#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

点击查看答案
第8题
有以下程序:#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

点击查看答案
第9题
有以下程序#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

点击查看答案
第10题
有以下程序:#include<stdio.h>void fun(int a,int b,int c){ a=456,b=567,c=678;}main(){ int x=

有以下程序: #include <stdio.h> void fun(int a,int b,int c) { a=456,b=567,c=678;} main() { int x=10,y=20,z=30; fun(x,y,z); printf("%d,%d,%d\n",x,y,z); } 此程序的输出结果是()。

A.30,20,10

B.10,20,30

C.456,567,678

D.678,567,456

点击查看答案
第11题
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

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