有以下程序
#include<stdio.h>
main()
{ int a=1,b=0;
if(--a)b++;
else if(a==0) b+=2;
else b+=3:
printf("%d\n",b);
}
程序运行后的输出结果是
A.0
B.1
C.2
D.3
第1题:
【填空题】当从键盘输入-1 0<CR>,则以下程序的运行结果是 。 #include<stdio.h> main() {int a,b,m,n; m=n=1; scanf("%d%d",&a,&b); do{if(a>0) {m=2*n;b++;} else {n=m+n;a+=2;b++;} }while(a==b); printf("m=%d n=%dn",m,n); }
第2题:
【单选题】以下程序的运行后的输出结果是_______。 #inlude <stdio.h> main() { int a=1,b=0; if(--a) b++; else if(a==0) b+=2; else b+=3; printf("%dn",b); }
A.0
B.1
C.2
D.3
第3题:
试题18
有以下程序
#include <stdio.h>
main()
{ int a=1,b=0;
if(- -a) b++;
else if(a= =0) b+=2;
else b==3;
printf(“%d\n”, b);
}
程序运行后的输出结果是()
A.0
B.1
C.2
D.3
第4题:
有以下程序
#include<stdio.h>
main( )
{int a=1,b=0
if(!a)b++;
else if(a==0)if(a)b+=2
else b+=3
printf(”%d\n”,b);
}
程序运行后的输出结果是( )。
A.0
B.1
C.2
D.3
第5题:
有以下程序 #include <stdio.h> main() { int x=1,y=0,a=0,b=0; switch(X) { case 1: switch(y) { case 0:a++; break; case 1:b++; break; } case 2:a++;b++;break; case 3:a++;b++; } printf("a=%d,b=%d\n",a,b); } 程序
A.a=1,b=0
B.a=2,b=2
C.a=1,b=1
D.a=2,b=1
第6题:
有以下程序:
#include<stdio.h>
main( )
{ int a=1,b=0;
if(--a)b++;
else if(a==0)b+=2;
else b+=3:
print[("%d\n",b);
}
程序运行后的输出结果是( )。
A.0
B.1
C.2
D.3
第7题:
有以下程序 #include<stdi0.h> void fun(int n,int*p) ( int f1,f2; if(n==1|| n==2)*p=1; else { fun(n-1,&f1);fun(n-2,&f2); *p=f1+f2; } } main { int s; fun(3,&s);printf("%d",s); } 程序的运行结果是( )。
A.2
B.3
C.4
D.5
第8题:
有以下程序
#include<stdi0.h>
void fun(int n,int*p)
( int f1,f2;
if(n==1|| n==2)*p=1;
else
{ fun(n-1,&f1);fun(n-2,&f2);
*p=f1+f2;
}
}
main
{ int s;
fun(3,&s);printf("%d",s);
}
程序的运行结果是( )。
A.2
B.3
C.4
D.5
第9题:
以下程序的输出结果是 #include<stdio.h> in[fun(int n,int *s) {int n,f2; if(n==0‖n==1) *s=1; else {fun(n-1,&f1); fun(n-2,&f2); *s=f1+f2; }} void main() { int x; fun(6,&x); pfintf("\n%d",x);}
A.7
B.13
C.9
D.10