单选题有以下程序段:char ch;int k;ch='a';k =12;printf(%c,%d,,ch,ch,k);printf(k=%d,k);已知字符a的ASCII码十进制值为97,则执行上述程序段后输出的结果是(  )。A因变量类型与格式描述符的类型不匹配输出无定值B输出项与格式描述符个数不符,输出为零值或不定值Ca,97,12k=12Da,97,k=12

单选题
有以下程序段:char ch;int k;ch='a';k =12;printf(%c,%d,,ch,ch,k);printf(k=%d,k);已知字符a的ASCII码十进制值为97,则执行上述程序段后输出的结果是(  )。
A

因变量类型与格式描述符的类型不匹配输出无定值

B

输出项与格式描述符个数不符,输出为零值或不定值

C

a,97,12k=12

D

a,97,k=12


参考解析

解析:
字符变量的值是该字符的ASCII码值,可以参与整型变量所允许的任何运算。“ch='a'”,%c表示以字符格式输出ch的值,所以输出为a;%d表示以十进制代码的形式输出ch的值,为97;k没有对应的输出格式,不输出。在第二个语句中,首先输出“k=”,然后以十进制代码输出k的值,为12。答案选择D选项。

相关考题:

有以下程序段char ch; int k;ch='a'; k=12;printf("%c,%d,",ch,ch,k); printf("k=%d\n",k);已知字符 a 的 ASCll 十进制代码为 97 ,则执行上述程序段后输出结果是 ( )A) 因变量类型与格式描述符的类型不匹配输出无定值B) 输出项与格式描述符个数不符,输出为零值或不定值C)a,97,12k=12D)a,97,k=12

有以下程序段 char ch; int k; ch='a'; k=12; pnntf("%c,%d,",ch,ch,k); printf("k二%d\n",k); 已知字符a的ASCII码值为97,则执行上述程序段后输出结果是A.因变量类型与格式描述符的类型不匹配输出无定值B.输出项与格式描述符个数不符,输出为零值或不定值C.a,97,12k=12D.a,97,k=12

有下列程序段:charch:intk:ch=a;k=12;printf(%c,%d,,ch,ch,k);printf(k=%d\n,k);已知字符a的ASCIl十进制代码为97,则执行上述程序段后输出结果是( )。A.因变量类型与格式描述符的类型不匹配输出无定值B.输出项与格式描述符个数不符,输出为零值或不定值C.a,97,12k=12D.a,97,k=12

浙大OJ 2987Misspelling WA 坐等专家指教 Misspelling is an art form that students seem to excel at. Write a program that removes the nth character from an input string. InputThe first line of input contains a single integer N, (1 = N = 1000) which is the number of datasets that follow. Each dataset consists of a single line of input containing M, a space, and a single word made up of uppercase letters only. M will be less than or equal to the length of the word. The length of the word is guaranteed to be less than or equal to 80. OutputFor each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, and the misspelled word. The misspelled word is the input word with the indicated character deleted. Sample Input44 MISSPELL1 PROGRAMMING7 CONTEST3 BALLOONSample Output1 MISPELL2 ROGRAMMING3 CONTES4 BALOON我的代码#includestdio.h#includestring.hint main(){ int n,i,m,k,j,char[90]; scanf("%d", for(i=0;in;i++) { scanf("%d", getchar(); scanf("%s", j=0; for(k=0;ch[k]!='\0';k++) { if(k!=(m-1)) { j=j+1; ch[j]=ch[k]; // 这个地方 我有点小疑问 如果m=4 那么 ch[1]=ch[0],ch[2] } ]=ch[1] ch[3]=ch[2] ch[4]=ch[4];ch[5]=ch[5]....... 最后 在 } 输出ch的时候 ch[0] =ch[1],这个地方不是会有重复吗? (新手问的问题可能有点白痴 呵呵) printf("%d\n",k+1); printf("%s\n",ch); } return 0;}

杭电2000 ASCII码排序 #includestdio.h#includestring.hint main(){ int n,ch[3],i,t,k,j; while(scanf("%d", for(i=0;i3;i++) { if(ch[i]ch[0]) { t=ch[0]; ch[0]=ch[i]; ch[i]=t; } } if(ch[2]ch[1]) { k=ch[2]; ch[2]=ch[1]; ch[1]=k; } for(j=0;j3;j++) { if(j==0) printf("%c",ch[0]); else printf(" %c",ch[j]); } printf("\n"); } return 0;}Problem Description输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。 Input输入数据有多组,每组占一行,有三个字符组成,之间无空格。 Output对于每组输入数据,输出一行,字符中间用一个空格分开。 Sample Inputqweasdzxc Sample Outpute q wa d sc x z

若ch为char型变量,k为int型变量(已知字符a的ASCIl码是97),则执行下列语句后输出的结果为( )。 ch=b; k=10: printf("%X,%o,",ch,ch,k); printf("k=%%d\n",k);A.因变量类型与格式描述符的类型不匹配,输出无定值B.输出项与格式描述符个数不符,输出为0值或不定值C.62,142,k=%dD.62,142,k=%l0

在执行以下程序时,如果从键盘上输入ABCdef,则输出为______。include main(){char 在执行以下程序时,如果从键盘上输入ABCdef<回车>,则输出为______。#include <stdio.h>main (){ char ch; while ((ch=getchar())!="\n") { if (ch>='A' ch<='B')ch=ch+32; else if (ch>='a' ch<='z')ch=ch-32; printf("%c",ch); } printf("\n");}A.ABCdefB.abcDEFC.abcD.DEF

有以下程序:includeunion pw{int i; char ch[2];}a;main(){a.ch[0]=13;a.ch[1]=0;prin 有以下程序: #include<stdio.h> union pw { int i; char ch[2]; }a; main() { a.ch[0]=13;a.ch[1]=0;printf("%d\n",a.i);} 程序的输出结果是( )。A.13B.14C.208D.209

有以下程序段 char eh; int k; ch='a'; k=12; printf("%c,%d,",ch,ch,k); printf("k=%d\n",k); 已知字符a的ASCII码值为97,则执行上述程序段后输出结果是A.因变量类型与格式描述符的类型不匹配输出无定值B.输出项与格式描述符个数不符,输出为零值或不定值C.a,97,12k=12D.a,97,k=12

有以下程序:includeunion pw{ int i;char ch[2];}a;main(){ a.ch[0]=13;a.ch[1]=0;pri 有以下程序: #include<stdio.h> union pw { int i; char ch[2];}a; main() { a.ch[0]=13;a.ch[1]=0;printf("%d\n",a.i);} 程序的输出结果是A.13B.14C.208D.209

有以下程序段 char ch;int k; ch='a';k=12; printf("%c,%d,",ch,ch,k); printf("k=%d\n",k); 已知字符a的ASCII十进制代码为97,则执行上述程序段后输出结果是( )。A.因变量类型与格式描述符的类型不匹配输出无定值B.输出项与格式描述符个数不符,输出为零值或不定值C.a,97,12k=12D.a,97,k=12

运行以下程序后,如果从键盘上输入shose后回车,则输出结果为 _______。 includevoid 运行以下程序后,如果从键盘上输入shose后回车,则输出结果为 _______。 # include<iostream.h> void main(){ int v1=0,v2=0,k=0; char ch[80]; cin>>ch; while(ch[k]){ switch(ch[k]){ case 's'; case 'h'; default: v1++1; case 'o': v2++; } k++; } cout<<v1<< ","<<v2<<end1; }A.2, 0B.5, 0C.4, 5D.2, 5

有下列程序段: char ch;int k; ch='a';k=12; printf("%c,%d,",ch,ch,k); printf("k=%d\n",k); 已知字符a的ASCII十进制代码为97,则执行上述程序段后输出结果是( )。A.因变量类型与格式描述符的类型不匹配输出无定值B.输出项与格式描述符个数不符,输出为零值或不定值C.a,97,12k=12D.a,97,k=12

阅读以下说明和c++码,将应填入(n)处的字名写在对应栏内。[说明] 从键盘输入一个字符ch,输出该字符在文本文件input.txt 的每一行中出现的次数。(必须调用函数鳋统计ch的出现次数,函数ff (str,ch)的功能是统计并返回字符ch在字符串str 中出现的次数。)。例如:如果文件input. txt 中存放了下列数据:every121I am a student运行程序,并输入e后,输出:201int ff( char * str, char ch){ int count =0;while ((1)) {if( *str= =ch) count++;str ++;}return count;}include < stdio. h >include < stdlib. h >void main( ){ char ch, c, s [80];int k;FILE *fp;if((2)){printf( “打不开文件!n”); return;}ch = getchar( );k=0;while( ! feof(fp) ) {c = fgete(fp);if (3)s[k++ ] =c;else {s[k]= ";printf ( "%dn" ,ff(s, ch) );k=0;}}(4)printf( "% dn", ff( s, ch ) );}

若ch为char型变量,k为int型变量(已知字符a的ASCII码是97),则执行下列语句后输出的结果为( )。 cb=b; k=10; printf("%X,%o,”,ch,ch,k); printf("k=%%d\n",k);A.因变量类型与格式描述符的类型不匹配,输出无定值B.输出项与格式描述符个数不符,输出为0值或不定值C.62,142,k=%dD.62,142,k=%10

阅读以下说明和C程序,填入(n)外。[说明]以下C程序实现了将字符串转化为浮点数的功能。例如字符串“1234567”转化为浮点数1234567;字符串“100.02035”转化为浮点数100.02035;字符串“-100.02035”转化为浮点数-100.02035。程序中的部分变量的含义如表9-5。[C程序]double StrToDouble(char*s){char hexch[]="0123456789";int i,j,psign=1;DWORD n,k,intpart=0;double doublepart=0,kdouble,resoult;char ch;if (*s=='.'{(1);(2);}char*s1=s,*temp=NULL;temp=strrchr ( s1,'.' );if (!temp){k=1; intpart=0;for (i=strlen (s); i>0;i--){ch=s[i-1];if (ch>0x3f) ch=0xDF;n=0;for (j=0; j<10; j++)if ( ch==hexch[j]) n=j;intpart+= (n*k);k*=10;}}else{s1=temp+1;kdouble=0.1;doublepart=0;for ((3)){ch=s1[i-1];if (ch>0x3f) ch=0xDF;n=0;for (j=0; j<10; j++ )if (ch==hexch[j])n=j;doublepart+= (n*kdouble);(4);}*temp=NULL;k=1; intpart=0;for ((5);){ch=s[i-1];if (ch>0x3f) ch=0xDF;n=0;for (j=0; j<10; j++)if (ch==hexch[j]) n=j;intpart+= (n*k);k*=10;}//end else}(6);return resoult;}

下面程序的输出结果是。 Private Sub Commandl_Click ch$=“ABCDEF” proc ch:Print ch End Sub Private Sub proc(ch As Stnng) s=“” For k=Len(ch) TO 1 Step -1 s=sMid(ch,k,1) Next k ch=s End Sub A.ABCDEF B.FEDCBA C.A D.F

下面程序的运行结果是#include #define SIZE 12sub(char *a,int t1,int t2) { char ch; while(t1t2) { ch=*(a+t1); *(a+t1)=*(a+t2); *(a+t2)=ch; t1++;t2--; }} main() { char s[SIZE]={’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’}; int i; sub(s,7,SIZE-1); for(i=0;iSIZE;i++) printf("%c ",s[i]); printf("\n");}

有以下程序#include stdio.hunion pw{ int i; char ch[2];}a;main(){ a.ch[0]=13;a.ch[1]=0; printf("%d\n",a.i);} 程序的输出结果是A.13 B.14C.0 D.20

有以下程序: include main() {char ch1,ch2;int n1,n2;ch1=getchar();ch2=getehar();n1 有以下程序:include <stdio.h>main(){ char ch1,ch2;int n1,n2;ch1=getchar();ch2=getehar();n1=ch1-'0'; n2=n1*10+(ch2-'0');printf("%d\n",n2);}程序运行时输入:12<回车>,执行后的输出结果是【 】。

下面程序的输出结果是______。includemain(){char ch[7]={"12ab56"}; int i,s=0; for(i 下面程序的输出结果是______。 #include<stdio.h> main() { char ch[7]={"12ab56"}; int i,s=0; for(i=0;ch[i]>='0'ch[i]<='9';i+=2) s=10*s+ch[i]-'0'; printf("%d\n",s); }A.1B.1256C.12ab56D.1 2 5 6

有以下程序:includeunion pw{int i; char ch[2]; } a;main(){a.ch[0]=13; a.ch[1]=0; 有以下程序: #include <stdio.h> union pw { int i; char ch[2]; } a; main() { a.ch[0]=13; a.ch[1]=0; printf("%d\n",a.i); } 程序的输出结果是(注意:ch[0]在低字节,ch[1]在高字节)( )。A.13B.14C.208D.209

在执行以下程序时,如果从键盘上输入:ABCdef,则输出为______。 main() { char ch; while((ch 在执行以下程序时,如果从键盘上输入:ABCdef<回车>,则输出为______。 main() { char ch; while((ch=getchar())!='\n') { if(ch>='A' ch<='Z') ch=ch+32; else if(ch>='a'ch<='2')ch=ch-32; printf("%c",ch); } printf("\n"); }A.ABCdefB.abcDEFC.abcD.DEF

有以下程序:#include stdio.hunion pw{ int i;char ch[2];}a;? main()? {a.ch[0]=13;a.ch[1]=0;printf( "%d\n",a.i);}程序的输出结果是A.13B.14C.208D.209

字符变量ch=’A’,int类型变量k=25,语句printf(”%3d,%d3/n”,ch,k);输出()。A、65,253B、65253C、65,25D、A25

若ch为char型变量,k为int型变量(已知字符a的ASCII十进制代码为97), 则以下程序段的执行结果是(). ch=’a’; k=12; printf("%x,%o,",ch,ch); printf("k=%%%d/n",k);A、因变量类型与格式描述符的类型不匹配,输出无定值B、输出项与格式描述符个数不符,输出为零值或不定值C、61,141,k=%12D、61,141,k=%d

单选题有如下程序:#includemain(){ charch='M'; while(ch!='K') {  ch--;  putchar(ch); } printf();}程序运行后的输出结果是(  )。AMNBLKCOPDMM