执行以下程序时输入1234567,则输出结果是【 】。 includemain(){int a=1,b; scanf("%2执行以下程序时输入1234567<CR>,则输出结果是【 】。include <stdio.h>main(){ int a=1,b;scanf("%2d%2d",&a,&b); prinff("%d %dhn",a,b);}

题目
执行以下程序时输入1234567,则输出结果是【 】。 includemain(){int a=1,b; scanf("%2

执行以下程序时输入1234567<CR>,则输出结果是【 】。

include <stdio.h>

main()

{ int a=1,b;

scanf("%2d%2d",&a,&b); prinff("%d %dhn",a,b);

}


相似考题
更多“执行以下程序时输入1234567<CR>,则输出结果是【 】。 include<stdio.h>main(){int a=1,b; scanf("%2 ”相关问题
  • 第1题:

    执行下面的程序时,输入abc(其中CR代表回车),输出结果是()。includeinclude

    执行下面的程序时,输入abc<CR>(其中CR代表回车),输出结果是( )。 #include<stdio.h> #include <string.h> main() { char ch; while((cn=getchar())!='n') { switch(ch-'a') { case 0: putchar(ch+1); case 1:putchar(ch+1);break; case 2:putchar(ch+2); caSe 3:putchar(ch+2);break; } } }

    A.abc

    B.bbc

    C.abcd

    D.bbcee


    正确答案:D
    解析:当ch='a'时,ch-'a'=0,进入case0分支输出b,再进入case1分支输出b,然后结束本次循环。当ch='b'时,'b'-'a'=1,进入case1分支输出c,然后结束本次循环。当ch='c'时,'c'-'a'=2,进入case2分支输出e,再进入case3分支输出e,然后结束次循环。遇到'-n'结束循环。显示输出为bbcee。

  • 第2题:

    以下程序运行后的输出结果是( )。 include main(){ int a=1, b=7; do { b=b/2; a+=b

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

    include<stdio.h>

    main()

    { int a=1, b=7;

    do {

    b=b/2; a+=b;

    } while(b>1);

    printf("%d\n",A);

    }


    正确答案:5
    5 解析:该程序考查do-while循环。循环共进行两次。第一次循环b=3,a=4;第二次循环b=1,a=5。输出a的值为5。

  • 第3题:

    当执行下面的程序时,如果输入ABC,则输出结果是 ( ) include include

    当执行下面的程序时,如果输入ABC,则输出结果是 ( ) # include<stdio.h> # include<string.h> main( ) { char ss [10] ="12345"; gets(ss);strcat(ss"6789");printf("%s\n",ss); }

    A.ABC6789

    B.ABC67

    C.12345ABC6

    D.ABC456789


    正确答案:A

  • 第4题:

    执行以下程序的输出结果是【 】。include main()[ inti, n[4]={1};for(i= 1 ;i<=3 ;i++){

    执行以下程序的输出结果是【 】。

    include <stdio.h>

    main()

    [ int i, n[4]={1};

    for(i= 1 ;i<=3 ;i++)

    { n[i]=n[i-1]*2+1; printf("%d",n[i]); }


    正确答案:3 715
    3 715 解析:本题考查的知识点是:for循环。本题主函数中的for循环从1递增到3,所以将循环3次。循环体中,n[i]=n[i-1]*2+1;语句使数组n从第2个元素开始,后一个元素等于前一个元素的2倍加1;print("%d",n[i]);输出刚计算出的数组n的元素。故结果应该是1*2+1=3、3*2+1:7、7*2+1=15。即输出结果为3 715。

  • 第5题:

    有以下程序:include int fun(int n){if(n == 1) return 1;else return( n + fun( n -

    有以下程序:#include <stdio.h>int fun(int n){ if(n == 1) return 1; else return( n + fun( n - 1 ) );}main( ){ int x; seanf("% d" ,&X) ;x = fun(x) ;pfinff( "% d \n" ,x);} 执行程序时,给变量x输入10,程序的输出结果是( )。

    A.55

    B.54

    C.65

    D.45


    正确答案:A
    解析:函数调用将实参x=10传给形参n,语句n=1不成立,执行else语句,递归调用fun函数。fun函数共被调用8次,即fun(9),fun(8),…,fun(2),由此可得n=10+9+…+1=55,所以x=55。

  • 第6题:

    以下程序的输出结果是()。include 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.#*#*$


    正确答案:C
    解析:程序中当i不能整除2时输出*,然后输出#,能够整除2时将结束本次循环,进入到下一次循环。当循环结束后,输出$。

  • 第7题:

    若执行下列程序时从键盘上输入2,则输出结果是()。 inclUde main() {int a; scanf("%d",

    若执行下列程序时从键盘上输入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


    正确答案:B
    解析:本题考查if else语句。程序中首先使用函数scanf()通过键盘读入a的值,并通过第1个if语句,先判断条件,取a的值2和3比较,然后将a的值加1,发现条件成立,执行下列的printf语句,输出a的值3。

  • 第8题:

    若执行下列的程序时,从键盘上输入1和2,则输出结果是( )。 include main(){ int a,b,s;s

    若执行下列的程序时,从键盘上输入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


    正确答案:B
    解析:本题考查if语句。scanf函数通过键盘读入a、b的值,a=1,b=2。第一个if语句,先判断条件,发现ab条件成立,则s=b=2, s=s*s=4。

  • 第9题:

    执行下列程序时输入456<空格>789<空格>123<回车>,输出结果是()。includemain(){char m[

    执行下列程序时输入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


    正确答案:D

  • 第10题:

    执行下列程序时输入12345678,程序的运行结果是______。 include main() { int x,y; sca

    执行下列程序时输入12345678,程序的运行结果是______。 #include<stdio.h> main() { int x,y; scanf("%2d%2d"); printf("%d\n",x+y); }

    A.17

    B.46

    C.15

    D.9


    正确答案:B

  • 第11题:

    下列程序运行时输入1234567,则输出结果是______。includemain(){ int a=1,b;scanf("

    下列程序运行时输入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。

  • 第12题:

    单选题
    有以下程序#include int fun(int n){ if(n==1)  return 1; else  return(n+fun(n-1));}main(){ int x; scanf(%d,&x); x=fun(x); printf(%d,x);}执行程序时,给变量x输入10,程序的输出结果是(  )。
    A

    55

    B

    54

    C

    65

    D

    45


    正确答案: C
    解析:
    fun函数是一个递归函数,用于求整数1到n的和。因此,主函数中最后输出1到10之间的整数和,即55。答案选择A选项。

  • 第13题:

    执行下面程序时,若输入1、-5、6,则输出结果为()。includeincludedefinedisc(a,

    执行下面程序时,若输入1、-5、6,则输出结果为( )。 # include <stdio.h> # include <math.h> # define disc(a,b,c) b*b-4*a*c main() { float x1,x2; int a,b,c; scanf("%d,%d,%d",&a,&b,&c); x1=(-b+sqrt(disc(a,b,c)))/(2*a); x2=(-b-sqrt(disc(a,b,c)))/(2*a); printf("%5.1f.%5.1f",x1,x2); }

    A.3,2

    B.3.0,2.0

    C.-3,-2

    D.程序出错


    正确答案:B
    解析:本题是使用带参数的宏来求解一元二次方程的两个根。表达式x1=(-b+sqrt(disc(a,b,c)))/(2*a)宏展开后为:x1=(-b+sqrt(b*b-4*a*c))/(2*a)=(5+sqrt(25-24))/2=6/2=3。表达式x2=(-b-sqrt(disc(a,b,c)))/(2*a)宏展开后为:x2=(-b-sqrt(b*b-4*a*c))/(2*a)=(5-sqrt(25-24))/2=4/2=2。所以程序输出结果为3.0,2.0,应该选择B。

  • 第14题:

    执行下列程序时输入:123<空格>456<空格>789<回车>,输出结果是()main(){ char s[100]int c,i;scan

    执行下列程序时输入:123<空格>456<空格>789<回车>,输出结果是( ) main() { char s[100] int c,i; scanf("%c",&C) ; scanf("%d",&i); scanf("%s",s); printf("%c,%d,%s\n",c,i,s); }

    A.1,456,789

    B.1,23,456

    C.1,23,456,789

    D.123,456,789


    正确答案:B

  • 第15题:

    以下程序的输出结果是() include main( ) { int a,b; for(a=1,b=1,a<=50;a+ +)

    以下程序的输出结果是 ( ) # include<stdio.h> main( ) { int a,b; for(a=1,b=1,a<=50;a+ +) { if(b>=10) break; if (b%2==1) { b+=2; continue } b+=2; } printf("%d\n",a); }

    A.4

    B.5

    C.6

    D.7


    正确答案:C

  • 第16题:

    执行程序时的输入为123456789,则程序的运行结果为( )。 include"stdio.h" main() { int a,b; scanf("%2d%*2d%1d",&a,&B); printf("%d\n",a-B); }


    正确答案:7
    7

  • 第17题:

    若执行下面的程序时,从键盘上输入5和2,则输出结果是includevoid main( ){int a,b,k

    若执行下面的程序时,从键盘上输入5和2,则输出结果是 #include<iostream.h> void main( ) { int a,b,k; cin >> a >> b; k=a; if(a<b) k=a%b; else k=b%a; cout < < k < < endl;}

    A.5

    B.3

    C.2

    D.0


    正确答案:C
    解析:本题考查简单的if…else语句。先执行条件if(ab) ,显然不成立,则执行else语句。

  • 第18题:

    以下程序的输出结果是______。includeincludefun(char*w,int n){ char t,*s

    以下程序的输出结果是______。 #include<stdio.h> #include<string.h> fun(char*w,int n) { char t,*s1,*s2; s1=w;s2=w+n-1; while(s1<s2) { t=*s1++; *s1=*s2-; *s2=t; } } main() { char*p; p="1234567"; fun(p,strlen(p)); puts(p); }

    A.1234567

    B.7654321

    C.1711717

    D.7177171


    正确答案:C
    解析:在子函数fun中,s1为字符串w的起始地址,s2为字符串的结束地址(字符'\0'除外),当执行循环结束循环, w="1711717"。

  • 第19题:

    若执行下述程序时,从键盘输入的数据是3和6,则程序的输出结果是()。includevoid main(){

    若执行下述程序时,从键盘输入的数据是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.有语法错误


    正确答案:B
    解析:变量x得到数据3,变量y得到数据6。z=6+3=9。xy即36关系表达式的值为1,执行z=y-x=6-3=3。最后输出z的值为3。

  • 第20题:

    以下程序的输出结果是_______。includeincludefun(char*w,int n){char t,*s

    以下程序的输出结果是_______。 #include<stdio.h> #include<string.h> fun(char*w,int n) { char t,*s1,*s2; s1=w;s2=w+n-1; while(s1<s2) { t=*s1++: *sl=*s2-; *s2=t; } } main() { char*p; p="1234567"; fun(p,strlen(p)); puts(p); }

    A.1234567

    B.7654321

    C.1711717

    D.7177171


    正确答案:C
    解析:在于函数fun中,s1为字符串w的起始地址,s2为字符串的结束地址(字符'\0'除外),当执行循环结束循环,w="1711717"。

  • 第21题:

    执行下列程序时输入:123<空格>456<空格>789<回车>输出结果是main(){char s[100];int c,i; scanf(

    执行下列程序时输入:123<空格>456<空格>789<回车>输出结果是 main() { char s[100];int c,i; scanf("%c",&c);scanf("%d",&i);scanf("%s",s); printf("%c,%d,%s\n",c,i,s);}

    A.123,456,789

    B.1,456,789

    C.1,23,456,789

    D.1,23,456


    正确答案:D
    解析:当执行输入时,把整数赋给字符型变量c(整型与字符型能相互转化),把23赋给整型变量i,把456赋给字符数组s,789之所以没有被接受是因为字符串输入时,遇空格结束。

  • 第22题:

    执行以下程序时输人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


    正确答案:D
    scanf函数中的格式控制说明为”%3d%2d”,分别选中输人中的三位和两位,因此a=123,b=45。因此正确答案为D)选项。

  • 第23题:

    执行以下程序时输入1234567<CR>,则输出结果是_[6]_______

    #include <stdio.h>

    main()

    { int a=1,b;

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


    正确答案:

    12 34