网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

【填空题】输入一个字符,如果它是大写字母,则把它变成小写字母,如果它是一个小写字母,则把它变成大写字母,其它字符不变。请分析程序填空。 main() {char ch; scanf("%c",&ch); if(【1】) ch=ch+32; else if(ch>='a'&&ch<='z') 【2】; printf("%c",ch); }


参考答案和解析
更多 “【填空题】输入一个字符,如果它是大写字母,则把它变成小写字母,如果它是一个小写字母,则把它变成大写字母,其它字符不变。请分析程序填空。 main() {char ch; scanf("%c",ch); if(【1】) ch=ch+32; else if(ch>='a'ch<='z') 【2】; printf("%c",ch); }” 相关考题
考题 下列程序运行时,若输入labced12df回车 输出结果为【10】#include stdio.hmain( ){char a =0,ch;while((ch=getchar())!=’\n’){if(a2!=0(ch’a’ch=’z’)) ch=ch-‘a’+’A’;a++;putchar(ch);}printf(“\n”);}

考题 下列程序运行时 , 若输入 labcedf2df 回车 输出结果为【 1 0 】#include stdio.hmain(){ char a=0,ch;while((ch=getch ar ())!='\n'){ if(a%2!=0(ch='a'ch='z')) ch=ch-'a'+'A';a++; putchar(ch);}printf("\n");}

考题 已知char ch=′C′;则以下表达式的值是ch=(ch=′A′ ch=′Z′)?(ch+32):ch;A.AB.aC.ZD.c

考题 请补充main函数,该函数的功能是:从键盘输入一个字符串及一个指定字符,然后把这个字符及其后面的所有字符全部删除。结果仍然保存在原串中。 例如,输入“abcdefg”,指定字符为“d”,则输出“abe”。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。 试题程序: includestdlib.h includestdio.h define M 80 void main { int i=0; char str[M]; char ch; system("CLS"); printf("\n Input a strin9:\n"); gets(str); printf("\n Input a charator;\n"); scanf("%c",&ch); while(str[i]!=\0) { if(str[i]==ch) 【1】 【2】 ; } str[i]=【3】 ; printf("\n***display string***\n"); puts(str); }

考题 下列给定的程序中,函数proc的功能是:判断字符ch 是,与str所指字符串中的某个字符相同;若相同,则什么也不做,若不同,则将其插在串的最后。请修改程序中的错误,使它能得出正确的结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: includestdlib.h includeconio.h includestdio.h includestring.h //****found**** void proc(char str,char ch) { while(*str &&*str!=ch)str++; //****found**** if(*str==ch) { str[0]=ch; //****found**** str[1]=0: } } void main { char str[81],ch; system("CLS"); printf("\nPlease enter a string:"); gets(str); printf("\n Please enter the character to search:"); ch=getchar; proc(str,ch); printf("\nThe result is%s\n",str); }

考题 3下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是( )。import java.io.*;public class Exam{public static void main(String args[]){ int ch=0; System.out.println("输入一个字符:"); try{ ch=System.in.readO; char ch_A='A', ch_ Z='Z'; int delta_c=(int)ch_A +(int)ch_Z-ch; System.out.println("编码后的字符为: "+(char)delta_c); } catch(IOException e){ e.printStackTrace(); } }}A.CB.YC.XD.字母C的ASCII码的整型值

考题 下列程序的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,输入字符1,则输出3,请填空。#include#include#define M 81int fun(char *ss, char c){ int i=0;for(; ( );ss++)if(*ss==c)i++;return i;}main(){ char a[M], ch;clrscr();printf("\nPlease enter a string: "); gets(a);printf("\nPlease enter a char: "); ch=getchar();printf("\nThe number of the char is: %d\n", fun(a,ch));}

考题 杭电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

考题 请补充函数fun(),该函数的功能是:返回字符数组中指定子符的个数,指定字符从键盘输入。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80int fun (char s[],char ch){int i=0, n=0;while(【 】){if(【 】)n++;i++;}【 】;}main ( ){int n;char str[N], ch;clrscr ();printf ("\nInput a string: \n");gets (str);printf ("\nInput a charactor: \n" ;scanf ("%c", ch);n=fun (str, ch);printf("\nnumber of %c:%d", ch, n);}

考题 在执行以下程序时,如果从键盘上输入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

考题 将小写字母'n'赋值给字符变量ch,正确的操作是( )。A.ch='\n'B.ch=110C.ch="n"D.ch='N'

考题 请编写函数fun(),它的功能是:求出ss所指字符串中指定字符的个数,并返回此值。例如,若输入字符串123412132,输入字符1,则输出3。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:include<coio.h>include<stdio.h>define M 81int fun(char *ss,char c){}main(){ char a[M],ch;clrscr();printf("\nPlease enter a string:");gets(a);printf("\nPlease enter a char:");ch=getchar();printf("\nThe number of the char is:%d \n",fun(a,ch));}

考题 阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。【说明】给定函数fun的功能是:将从键盘上输入的每个单词的第一个字母转换为大写字母,输入时各单词必须用空格隔开,用“.”结束输入。【函数】int fun(char *c,int status){if((1)=='')return 1;else{if((2)(3)(4))(5)='A'-'a';return 0;}}main(){int flag=1;char ch;printf("请输入一字符串,用点号结束输入!\n");do {ch=getchar();flag=fun(ch,flag);putchar(ch);}while(ch!='.');printf("\n");}

考题 设有如下程序 # include main() { char ch1='A',ch2='a'; printf("%c\n",(ch1,ch2)); } 则下列叙述正确的为( )A. 程序的输出结果为大写字母AB. 程序的输出结果为小写字母aC. 运行时产生错误信息D. 格式说明符的个数少于输出项的个数,编译出错

考题 下列程序的功能是:求出ss字符串中指定字符c的个数,并返回此值。请编写函数int num(*char ss,char c)以实现程序要求,最后调用函数readwriteDat(),把结果输出到文件out.dat中(注:大小写字母有区别)。例如:若输入字符串“ss="123412132" , c=’1’”,则输出“3”。部分源程序已给出。请勿改动主函数main()和输出数据函数writeDat()的内容。#include conio.h#include stdio.h#define M 81void readwriteDAT(); int num(char *ss,char c){ } main(){ char a[M],ch; clrscr(); printf("\nPlease enter a string:" );gets(a); printf("\nPlease enter a char;" );ch=getchar(); printf("\nThe number of the char is:%d\n" ,num(a,ch)); readwriteDAT();}viod readwriteDAT(){ int i; FILE *rf,*wf; char a[M],b[M],ch; rf=fopen("in.dat" ,"r" ); wf=fopen(" out.dat" ,"w" ); for(i=0;i10;i++){ fscanf(rf," %s",a); fscanf(rf," %s" ,b); ch=*b; fprintf(wf," %c=%d\n:" ,ch,num(a,ch));} fclose(rf); fclose(wf);}

考题 下列程序运行时,若输入labcedf2df输出结果为【】。 include main(){char a=0,ch; wh 下列程序运行时,若输入labcedf2df<回车>输出结果为【 】。include<stdio.h>main(){ char a=0,ch;while((ch==getchar())!='\n'){ if(a%2!=0(ch>='a'ch<='z')) ch=ch'a'+'A';a++;prtchar(ch);}printf("\n");}

考题 阅读以下说明和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 ) );}

考题 请补充函数fun(),该函数的功能是;删除字符数组中小于等于指定字符的字符,指定字符从键盘输入,结果仍保存例如,输入“abcdefghij”,指定字符为‘d’,则结果输出“defghij”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio. h>define N 80void fun (char s[], char ch){int i=0, j=0;while (s [i] ){if (s Iii<ch)【 】;else{【 】i++;}}【 】}main (){char str [N], ch;clrscr ();printf("\n Input a string:\n");gets (str);printf("\n*** original string ***\n");puts (str);printf("\n Input a character:\n");scanf ("%c", ch);fun(str, ch);printf("\n*** new string ***\n");puts (str);}

考题 下面程序中,若从键盘输入大写字母C,则程序的输出结果是______。 import java.io.*; public class Test{ public static void main(String args[ ]){ int ch=0; System.out.println("Please input a character:"); try{ ch=System.in.read( ); char ch_A='A',ch_Z='Z'; int delta_c=(int)ch_A+(int)ch_Z-ch; System.Out.println("the encoded character is:"+(char)delta_C); }catch(IOException e){e.printStackTrace( );} } }A.CB.YC.XD.字母C的ASCII码的整型值

考题 下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是( )。 Importjava.io.*; public class Exam{ public static void main(String args[]){ int ch=0; System.out.println("输入一个字符:"); try{ ch=System.in.read; charch_A='A',ch_Z='Z'; int delta c=(int)ch A+(int)ch Z-ch; syStem. out.println("编码后的字符为:"+(char)delta_c); } catch(IOException e){ printStackTrace; } } }A.CB.YC.XD.字母C的ASCIl码的整型值

考题 若有char ch[10],则下列字符串数组的赋值中不正确的是( )。A.ch="welcome";B.ch[0]='w';C.strcpy(ch,"welcome");D.char ch1[]="welcome";strcpy(ch,ch1);

考题 下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是( )。 Importjava.io.*; publicclassExam{ publicstaticvoidmain(Stringargs[]){ intch=0; System.out.println("输入一个字符:"); try{ ch=System.in.read(); charch_A='A',ch_Z='Z'; intdelta_c=(inoch_A+(int)ch_Z-ch; System.out.println("编码后的字符为:"+(char)delta_c); } catch(IOExceptione){ e.printStackTrace(); } } }A.CB.YC.XD.字母C的ASCII码的整型值

考题 下列函数的功能是()。includeusing namespace std;void main(){ char a;int i; cin>>a 下列函数的功能是( )。 #include<iostream> using namespace std; void main() { char a;int i; cin>>a; for(i=1;i<=10;i++) { if((a>= 'a')(a<= 'z')) a=a-i; cout<<a; } }A.把a中的小写字母变成大写字母B.把a中的大写字母变成小写字母C.把a中的所有字母变成小写字母D.把a中的字符变成它前面i个的字符

考题 设ch是char型变量,其值为'A',则下面表达式的值是( )。 ch=(ch>='A'ch<='Z')? (ch+32):chA.AB.aC.ZD.z

考题 在执行以下程序时,如果从键盘上输入: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

考题 下列语句应将小写字母转换为大写字母,其中正确的是()。A、if(ch=’a’ch=’z’)ch=ch-32;B、if(ch=’a’ch=’z’)ch=ch-32;C、ch=(ch=’a’ch=’z’)?ch-32:’’;D、ch=(ch’a’ch’z’)?ch-32:ch;

考题 下列选项中,能有效声明一个字符的语句有()。A、char ch=’a’;B、char ch=’/’’;C、char ch=’cafe’;D、char ch="cafe";E、char ch=’/ucafe’;F、char ch=’/u10100’;G、char ch=(char)true;

考题 判断char型变量ch是否为小写字母的正确表达式是()A、’a’=ch=’z’B、(ch=’a’)(ch=’z’)C、(ch=’a’)(ch=’z’)D、(’a’=ch)AND(’z’=ch)