下列程序运行时输入1234567<CR>,则输出结果是______。
include<stdio.h>
main()
{ int a=1,b;
scanf("%2d%2d",&a,&b);printf("%d %d\n", a,b);
}
本题考查的重点是scanf函数的调用。scanf(“格式化字符串>”,地址表>),格式化字符串后可以加上场宽,本题中两个变量的场宽都为2,所以输入1234567CR>后,变量a的值为12。变址b的值为34,从而输出为12 34。
第1题:
下列程序的输出结果是( )。 #include<stdio.h> void main() { int b[6]={2,4,6,8,10,12}; int*p--b,**q=&p; printf("%d",*(p++)); printf("%d",**q); }
A.*p=&a;scanf("%1f",p);
B.*p=&a;scanf("%f",p);
C.p=&a;scanf("%1f",*p);
D.p=&a;scanf("%1f",p);
第2题:
以下程序运行后的输出结果是( )。
include<stdio.h>
main()
{ int a=1, b=7;
do {
b=b/2; a+=b;
} while(b>1);
printf("%d\n",A);
}
第3题:
执行程序时的输入为123456789,则程序的运行结果为( )。 include"stdio.h" main() { int a,b; scanf("%2d%*2d%1d",&a,&B); printf("%d\n",a-B); }
第4题:
以下程序的输出结果是( )。 #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.#*#*$
第5题:
若执行下列程序时从键盘上输入2,则输出结果是( )。
#inclUde<stdio.h>
main()
{int a;
scanf("%d",&A);
if(a++<3)
printf("%d\n",A);
else printf("%d\n",a--);
}
A.1
B.3
C.2
D.4
第6题:
有以下程序 #include <stdio.h> main() { int x; scanf("%d",&x); if(x<=3); else if(x!=1O) printf("%d\n",x); } 程序运行时,输入的值在______范围才会有输出结果。
A.不等于10的整数
B.大于3且不等10的整数
C.大于3或等于10的整数
D.小于3的整数
第7题:
若执行下述程序时,从键盘输入的数据是3和6,则程序的输出结果是( )。 #include <stdio.h> void main() {int x,y,z; scanf("%d%d",&X,&y); z = y + x; if (x<y) z = y + x; printf("%d",z); }
A.9
B.3
C.0
D.有语法错误
第8题:
执行下列程序时输入456<空格>789<空格>123<回车>,输出结果是( )。 #include<stdio.h> main() {char m[80]; int c,i; scanf("%c",&C); scanf("%d",&i); scanf("%s",&m); printf("%c,%d,%s\n",c,i,m); }
A.4.56789e+008
B.4.78912e+006
C.4,56,789,123
D.4,56.789
第9题:
执行下列程序时输入12345678,程序的运行结果是______。 #include<stdio.h> main() { int x,y; scanf("%2d%2d"); printf("%d\n",x+y); }
A.17
B.46
C.15
D.9
第10题:
有以下程序: #include <stdio.h> main() { char k; int i; for(i=1;i<3;i++) { scanf("%c",&k); switch(k) { case '0': printf("another\n"); case '1': printf("number\n"); } { } 程序运行时,从键盘输入:01<回车>,程序执行后的输出结果是( )。
A.another number
B.another number another
C.another number
D.number number
第11题:
下列程序的输出结果是( )。 #include<stdio.h> main() { int a=4; print f("%d\n", (a+=a-=a*a)); }
A.-8
B.14
C.0
D.-24
第12题:
执行以下程序时输入1234567<CR>,则输出结果是_[6]_______
#include <stdio.h>
main()
{ int a=1,b;
scanf("%2d%2d",&a&b);printf("%d %d\n",a,b);
12 34
第13题:
A.186
B.256
C.324
D.400
第14题:
若运行输入:3<回车>,则以下程序的输出结果是( )。 main() {int a,b; scanf("%d",&A); b=(a>=0)?a:-a; printf("b=%d",B); }
第15题:
下列程序的输出结果是( )。 #include<stdio.h> int b=2; int fune(int*a) { b+=*a;return b;} main() { int a=1,t=2; t+=func(&a); printf("%d\n",t); }
A.4
B.5
C.6
D.8
第16题:
有以下程序#include <stdio.h>main{ int x,y; scanf("%2d%ld",&x,&y); printf("%d\n",x+y);}程序运行时输入:1234567,程序的运行结果是
第17题:
设有下列程序:
include<stdio.h>
include<string.h>
main()
{ int i;
char si 10],ti 10];
gets(t);
for(i=0;i<2;i++)
{ gets(s);
if(strcmp(t,s)<0)strcpy(t,s);
}
printf("%s\n",t);
}
程序运行后,从键盘上输入(<CR>代表回车符):CDEF<CR>BADEF<CR>QTHRG<CR>,则程序的输出结果是______。
第18题:
以下程序的输出结果是#include "stdio.h"main(){ int a=065; printf("%d\n",--a);}
第19题:
若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。 #include<stdio.h> main() { int a,b,s; scanf("%d%d",&a,&b); s=a; if(a<b) s=b; s=s*s; printf("%d\n",s); }
A.1
B.4
C.2
D.9
第20题:
下列程序的输出结果是( )。
#include<stdio.h>
main()
{ int i;
for(i=1;i<=10;i++)
{ if((i*i>=20) &&(i*i<=100) )
break;
}
printf("%d\n",i*i);
}
A.49
B.36
C.25
D.64
第21题:
执行以下程序时输人1234567<CR>,则输出结果是( )。 #include<stdio.h> main { int a =1,b; scanf("%3d%2d",&a,&b); printf("%d%d\n",a,b); }
A.12367
B.12346
C.12312
D.12345
第22题:
下列程序的输出结果是( )。
#include<stdio.h>
main()
{ int a=4;
printf("%d\n",(a+=a-=a*A) );
}
A.-8
B.14
C.0
D.-24
第23题:
执行以下程序时输入1234567<CR>,则输出结果是【 】。
include <stdio.h>
main()
{ int a=1,b;
scanf("%2d%2d",&a,&b); prinff("%d %dhn",a,b);
}