下面程序的运行结果是( )。#includeint main(){int i=1,a=0,s=1;do{a=a+s*i;s=-s;i++;}while (i<=10);printf(“a=%d”,a);return 0;}
查看答案
当运行以下程序时,从键盘键入1 2 3 4 5 -1<回车>,则下面程序的运行结果是( )。#includeint main(){int k=0,n;do {scanf(“%d”,&n);k+=n;}while (n!=-1);printf(“k=%d,n=%d\n”,k,n);return 0;}
下面程序的运行结果是( )。#includeint main(){int x=-5;do {printf(“%3d”,x+=2);}while (!(x++));return 0;}
当运行以下程序时,从键盘键入:ABCdef <回车>,则输出为( )。#includeint main(){char ch;while((ch=getchar())!=‘\n’){if (ch>=‘A’&&ch<=’Z’) ch=ch+32;else if (ch>=‘a’&&ch<=’z’) ch=ch-32;printf(“%c”,ch);}printf(“\n”);return 0;}
当运行以下程序时,从键盘键入:student# <回车>,则输出结果为( )。#includeint main(){int v1=0,v2=0;char ch;while((ch=getchar())!=’#’)switch(ch){case ’d’:case ‘t’:default: v1++;case ‘a’:v2++;}printf(“%d,%d\n”,v1,v2);return 0;}