因变量类型与格式描述符的类型不匹配输出无定值
输出项与格式描述符个数不符,输出为零值或不定值
a,97,12k=12
a,97,k=12
第1题:
有下列程序段:
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=12
D.a,97,k=12
D。【解析】printf语句在输出时,格式说明与输出项的个数应该相同。如果格式说明的个数少于输出项的个数(正如本题的情况),则多余的输出项不予输出,如果格式说明个数多于输出项个数,则对于多余的格式项输出不定值或0。故本题选项为D。
第2题:
#include<stdio.h>#include<string.h>int main(){ int n,ch[3],i,t,k,j; while(scanf("%d",&n)!=EOF) { scanf("%s",ch); for(i=0;i<3;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;j<3;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
第3题:
有以下程序段
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=12
D)a,97,k=12
第4题:
有以下程序段 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=12
D.a,97,k=12
第5题:
在执行以下程序时,如果从键盘上输入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.ABCdef
B.abcDEF
C.abc
D.DEF
第6题:
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我的代码#include<stdio.h>#include<string.h>int main(){ int n,i,m,k,j,char[90]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&m); getchar(); scanf("%s",&ch); 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;}
第7题:
若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=%d
D.62,142,k=%l0
第8题:
有以下程序段 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=12
D.a,97,k=12
第9题:
有以下程序: #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.13
B.14
C.208
D.209
第10题:
有以下程序: #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.13
B.14
C.208
D.209