下面程序段的功能是将字符串str逆序存放,两处横线中应填 ; (两处需要填的内容相同,只写一次) int i,j,m; for(i=0,j=strlen(str);i<j;i++,j--) { m = str[i]; str[i] =_____________; ____________= m; }

下面程序段的功能是将字符串str逆序存放,两处横线中应填 ; (两处需要填的内容相同,只写一次) int i,j,m; for(i=0,j=strlen(str);i<j;i++,j--) { m = str[i]; str[i] =_____________; ____________= m; }


参考答案和解析
[SI] SI MOV DL,-1

相关考题:

下面程序的功能是将一个字符串str的内容颠倒过来,请填空。includemain(){ infi,j, [13] 下面程序的功能是将一个字符串str的内容颠倒过来,请填空。include<string.h>main(){ infi,j, [13] ;char str[]={"1234567"};for(i=0,j=strlen(str) [14] ;i<j;i++,j--){k=str[i];str[i]=str[i];str[j]=k;}printf("%s\n",str);}

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为include include i 阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 #include <stdio.h> #include <ctype.h> #include <string.h> int fun(char*str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81];A.asdafaaz67B.asdafaa267C.asdD.z67

下列给定程序中,函数proc的功能是:读入一个字符串(长度20),将该字符串中的所有字符按ASCIl码升序排序后输出。 例如,输入opdye,则应输出deopy。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: include%string.h include%stdlib.h includeconio.h includestdio.h //****found**** int proc(char str[]) { char C; unsigned i,j; for(i=0;istrlen(str)-1;i++) for(j=i+1;jstrlen(str);j4-+) if(str[i]str[j]) { c=str[j]: //****found**** str[j]=str[i++]; str[i]=C; } } void main { char st/[81]; system("CLS"); printf("\nPlease enter a character string:"); gets(str); printf("\nknBefore sorting:\n %s",str); proc(str); printf("\nAfter sorting decendingly:\n %S",str); }

请补充函数proc,该函数的功能是按条件删除一个字符串指定字符一半的数目,具体要求如下:如果该字符串所包含的指定字符的个数是奇数,则不删除,如果其数目是偶数,则删除原串后半部分的指定字符。其中,str指向原字符串,删除后的字符串存放在b所指的数组中,c中存放指定的字符。例如,当str输入“abcabcabcab”,c=b时,b的输出为“abcabcaca”;如果str的输入为“abcabcabca”,则b的输出为“abcabcabca”。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅程函数prOC的横线上填入所编写的若干表达式或语句。 试题程序: includestdlib.h includestdio.h includeconio.h define M 80 void proc(char str[],char b[],char c) { int i=0,j=0; int n=0: int m=0: while(str[i]!=\0) { if(str[i]==c) n++: i++: } 【1】 ; if(n%2) { while(str[j]!=\0 ) { b[j]=str[j]; j++; } b[j]=\0; } else { while(str[i]!=\0 ) { b[j++]=str[i]; if(str[i]==c) m++: if((mn/2)&&(str[i]==c)) 【2】 ; i++: } 【3】 ; } } void main { char str[M],b[M]; char C; system("CLS"); printf("Enter the strin9:\n"); gets(str); printf("Enter the character of the string deleted:"): scanf("%C",&c); proc(str,b,c); printf("The new string is:%s\n",b); }

下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在横线处填上适当内容,实现该函数。 Boo1 fun (char*str) { int i=0,j=0; while(str[j]j++; for(j--;i<jstr[i]==str[j];i++,j--); return i ______ j; }A.>==B.||C.D.<==

下列程序的运行结果为()。 include voidabc(Char*str) {inta,b,i,j; for(i=j=0;str[i]! 下列程序的运行结果为( )。#include<stdio.h>voidabc(Char*str){ inta,b,i,j;for(i=j=0;str[i]!='\0';i++)if(str[i]!='a')str[j++]=str[i];str[j]='\0';}void main(){ char str[]="abcdef";abc(str);printf("str[]=%s",str);}A.str[]=bcdefB.str[]=abcdefC.str[]=aD.str[]=ab

请补充函数fun(),该函数的功能是:把字符下标为非素数的字符从字符串sb中删除,把字符下标为素数的字符重新保存在字符串e口中。字符串sb从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdefghijkl”,输出“cdfhl”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char s[],int n){int i, j, k, flag;【 】;for(i=0; i<n; i++){if (i>1)s [k++] =s [i];flag=I;for(【 】; j<iflag; j++)if (i%j==0){flag=0;【 】}}s [k]='\0';}main(){int i=0, strlen=0;char str[N];clrscr ();printf("\n Input a string:\n");gets (str);while (str [i] !='\0'){strlen++;i++;}fun (str, strlen);printf("\n*** display string ***\n");puts (str);}

请补充函数fun(),该函数的功能是:把ASCII码为奇数的字符从字符串str中删除,结果仍然保存在字符串str中。字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdef”,输出“bdf”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun(char s[],int n){int i, j;j=0;for(i=0;【 】;i++){if(【 】)s [j++]-s [i];}【 】;}main ( ){int i=0, strlen=0;char str [N];clrscr ();printf ("\nInput a string: \n");gets (str);while (str [i] !='\0'){strlen++;i++;}fun(str, strlen);printf("\n*** display string ***\n");puts (str);}

下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false。请在画线处填上适当内容,实现该函数。bool fun(char*str)}int i:0,j=0;while(str[j]) (6) ;for(J--;i<jstr[i]==str[J];i++,J--);return i (7) J;}

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为#include#include#includeint fun (char *str){ int i,j=0;for(i=0;str[i]!=′\0′;i++)if(str[i]!=′ ′)str[j++]=str[i];str[j]= ′\0′;}main(){char str[81];int n;clrscr();printf("Input a string : ");gets(str);puts(str);fun(str);printf("%s\n",str);}A.asdafaaz67B.asd af aa z67C.asdD.z67

下列程序的运行结果为()。includevoidabc(char*str){int a,b,i,j;for(i=j=0;str[i]!='\ 下列程序的运行结果为( )。#include<stdio.h>voidabc(char*str){int a,b,i,j;for(i=j=0;str[i]!='\0';i++)if(str[i]!='a')str[j++]=str[j];str[j]='\0';}void main(){char Str[]="abcdef';abc(str);printf("str[]=%s",str);}A.str[]=bcdefB.str[]=abcdefC.str[]=aD.str[]=ab

这程序有错吗? /*写一个函数,用来返回一个字符串中重复出现的最长字串的长度及其开始地址const char*p=NULL;int len=maxsubstr("qweohiuweyowohifpw",输出:len=3,substr=ohi*/#includestdio.h#includestring.hint maxsubstr(const char *str,const char **p){ int len=0,templen=0;//len为字符串中重复出现的最长字串的长度,templen为判断过程中字符串中重复出现的字串的长度 int size=strlen(str); const char*i=str,*j=0; //i=str即i=str[0],i指向字符串的第一个字符 for(i=str;istr+size;i++){ //i依次指向字符串内的各个字符 const char *temp_i=i; //temp_i指向当前i所指字符 for(j=i+1;jstr+size;++j){ //j指向当前i所指字符的下一个字符,temp_i、j依次在总字符串中取两个字符串,temp_i在前,即在temp_i后寻找 与从temp_i开始的字符串重复长度最长的字符串 if(*temp_i==*j ++temp_i; } else if(*temp_i==*j ++temp_i; } else{ //当前所指字符不相等,temp_i需要指回i所指位置,j指回此次循环开始位置(由于for循环有++j,实际下次循环开始时往后指了一个) if(templenlen){ //判断重复出现的最长字串的长度是否改变 len=templen; templen=0; *p=i; }else{ templen=0; //就算重复出现的最长字串的长度不改变,当前长度也得清零。。。 } } } } return len;}int main(){ char str[10000]; const char*p=0; int len=0; int i=0; printf("输入带重复字符的字符串"); scanf("%s",str); len=maxsubstr(str, printf("len=%d,substr=",len); for(i=0;ilen;i++){ printf("%c",*p++); } printf("\n");}

阅读以下函数说明和C语言函数,将应填入(n)处的语句写在对应栏内。【函数1.1说明】本程序可以打印出如下图形(菱形):*************************【函数2.1】main(){int i,j,k;for(i=0;i<=3;i++){for(j=0;j<=2-i;j++)printf(" ");for((1))printf("*");printf("\n");}for(i=0;i<=2;i++){for((2))printf(" ");for(k=0;k<=4-2*i;k++)printf("*");printf("\n");}}【函数2.2说明】通过本程序,可以从键盘输入一个字符串,将小写字母全部转换成大写字母,然后输出到一个磁盘文件“CsaiWgm”中保存,输入的字符串以“!”结束。【函数2.2】include "stdio.h"main(){FILE *fp;char str[100],filename[10];int i=0;if((fp=fopen("CsaiWgm","w"))==NULL){printf("cannot open the file\n");exit(0);}printf("please input a string:\n");gets(str);while((3)){if(str[i]>='a'str[i]<='z')str[i]=(4);fputc(str[i],fp);(5);}fclose(fp);fp=fopen("CsaiWgm","r");fgets(str,stden(str)+1,fp);printf("%s\n",str);fclose(fp);}

请补充函数fun(),该函数的功能是:把字符串str中的字符按字符的ASCⅡ码降序排列,处理后的字符串仍然保存在原串中,字符串及其长度作为函数参数传入。例如,如果输入“cdefgh”,则输出为“hgfedc”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include <stdio.h>define N 80void fun (char s [], int n){int i, j;char ch;for (i=0; i<n; i++)for(j=【 】;j<n;j++)if (s[i]<s [j]){ch=s [j];【 】;s [i] =ch;}main ( ){int i=0, strlen=0;char str [N];clrscr ();printf ("\nInput a string: \n");gets (str);while (str [i] !=' \0'){strlen++;i++;}fun (str, strlen);printf ("\n***display string ***\n");puts (str);}

函数f_str(char *str,char del)的功能是;将非申字符串str分割成若干个子字符串并输出,del表示分割时的标志字符。例如,若str的值为“66981636666257”,del的值为“6”,调用此函数后,将输出3个子字符串,分别为“981”、“3”和“257”。请将函数f_str中(6)~(8)空缺处的内容填写完整。[函数]void f_str(char *str,char del){ int i,j,len;len = strlen(str);i = 0;while (i<len) {while ( (6) )i++; /* 忽略连续的标志字符 *//* 寻找从srt[i]开始直到标志字符出现的一个子字符串 */j = i+1;while (str[j] !=del str[j] !='\0')j++;(7)="\0"; /* 给找到的字符序列置字符串结束标志 */printf (" %s\t", str [i]);(8);}}

下列程序的运行结果为()。includevoid abc(char*str){int a,b,i,j; for(i=j=0;str[i]!= 下列程序的运行结果为( )。 #include<stdio.h> void abc(char*str) { int a,b,i,j; for(i=j=0;str[i]!='\0';i++) if(str[i]!='a' str[j++]=str[i]; str[j]='\0'; } void main() { char str[]="abcdef"; abc(str); printf("str[]=%s",str); }A.str[]=bcdefB.str[]=abcdefC.str[]=aD.str[]=ab

下列函数的功能是判断字符串str是否对称,对称则返回true,否则返回false,则横线处应填上( )。 Bool fun(char*str) { int i=0,j=0; while(str[j])j++; for(j--;i<jstr[i]==str[j];i++,j--); return i______j; }A.>==B.||C.D.<==

如下程序:includevoid main(){char str[2][5]={"1234","5678"),*p[2];int i,j,s=0; 如下程序: #include<iostream.h> void main() { char str[2][5]={"1234","5678"),*p[2]; int i,j,s=0; for(i=0;i<2;i++)p[i]=str[i]; for(i=0;i<2;i++) for(j=0;p[i][j]>'\0';j+=2) s=10*s+p[i][j]-'0'; cout<<s; } 该程序的输出结果是( )。A.1357B.2468C.3556D.23678

如下程序段#include stdio.h#include ctype.h#include conio.hint fun (char *str){ int i,j=0; for(i=0;str[i]!= ’\0’;i++) if(str[i]!= ’ ’)str[j++]=str[i]; str[j]= ’\0’;}main(){ char str[81]; int n; clrscr(); printf("Input a string : "); gets(str); fun(str); printf("%s\n",str);}当运行程序时,输入asd af aa z67回车,则输出是A.asdafaaz67 B.asd af aa z67 C.asd D.z67

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为includeincludeinc 阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 #include<stdio.h> #include<ctype.h> #include<string.h> int fun(char*str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81]; int n; clrscr(); printf("Input a string:"); gets(str); puts(str); fun(str); printf("%s\n",str); }A.asdafaaz67B.asdafaaz67C.asdD.z67

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为includeincludeine 阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 #include <stdio.h> #include <ctype.h> #inelude <string.h> int fun(char *str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81]; int n; printf("Input a string:"); gets(str); puts(str); fun(str); printf("%s\n",str); }A.asdafaaz67B.asd af aa z67C.asdD.z67

请补充函数fun(),该函数的功能是:把ASCⅡ码为偶数的字符从字符串s打中删除,结果仍然保存在字符串srt中,字符串str从键盘输入,其长度作为参数传入函数fun()。例如,输入“abcdef”,输出“ace”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:inc lude< stdio, h>define N 80【 】{int i, j;【 】for (i=0;i<n;i++){if (s [i] %2!=0)s [j++]=s [i];}【 】;}main ( ){int i=0, strlen=0;char str[N];clrscr ();printf ("\nInput a string:\n");gets (str);while (str [i] !=' \0' ){strlen++;i++;}fun (str, strlen);printf("\n*** display string ***\n");puts (str);}

下列给定程序中,函数proc的功能是:读入一个字符串(长度20),将该字符串中的所有字符按ASCII码升序排序后输出。 例如,输入opdye,则应输出deopy。 请修改程序中的错误,使它能得到正确结果。 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: includestring.h includestdlib.h includeconio.h includestdio.h //****found**** int proc(char str[]) { char c; unsigned i,j; for(i=0;istrlen(str)-1;i++) for(j=i+1;jstrlen(str);j++) if(str[i]str[j]) { c=str[j]: //****found**** str[j]=str[i++]; str[i]=c; } } void main { char str[81]; system("CLS"); printf("\nPlease enter a character string:"); gets(str); printf("\n\nBefore sorting:\n%s",str); proc(str); printf("\nAfter sorting decendingly:\n %s",str); }

请补充函数fun(),该函数的功能是:把从主函数中输入的字符串str2倒置后接在字符串str1后面。例如:str1=“How do”,str2=“?od uoy”,结果输出:“How do you do?”。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<stdio.h>include<conio.h>define N 40void fun(char *str1,char *str2){int i=0,j=0,k=0,n;char ch;char *p1=str1;char *p2=str2;while(*(p1+i))i++;while(*(p2+j))j++;n=【 】;for(;k=j/2;k++,j--){ch=*(p2+k);*(p2+k)=*(p2+j);*(p2+j)=ch;}【 】;for(;【 】;i++)*(p1+i)=*p2++;*(p1+i)='\0';}main(){char str1[N],str2[N];int m,n,k;clrscr();printf("***Input the string str1 str2***\n");printf("\nstr1:");gets(str1);printf("\nstr2:");gets(str2);printf("***The string str1 str2 ***\n");puts(str1);puts(str2);fun(str1,str2);printf("*** The new string ***\n");puts (str1);}

阅读下列函数说明和C函数,将应填入(n)处的字句写在对应栏内。[函数2.1说明]Fibonacci数列中头两个数均为1,从第三个数开始,每个数等于前两个数之和。下述程序计算Fibonacci数列中前15个数,并以每行5个数的格式输出。[函数2.1]include <stdio.h>main(){ int i,f,f1=1,f2=1;printf("%5d%5d",f1,f2);for(i=3;i<=15;i++){f=(1);printf("%5d",f);if((2)= =0) printf("\n");f1=12;(3);}}[函数2.2说明]函数fun(char *str1,char *str2)的功能是将字符串str2拼接到str1之后。[函数2.2]fun(char *str1,char *str2){ int i,j;for(i=0;str1[i]!='\0';i++);for(j=0;str2[j]!='\0';j++) (4);(5);}

阅读下列程序,当运行程序时,输入asd af aa z67,则输出为()。includeint fun (char *str 阅读下列程序,当运行程序时,输入asd af aa z67,则输出为( )。 #include <sldio.h> int fun (char *str) { int i,j=0; for(i=0;str[i]! ='\0';i++) if(str[i]! =") str[j++]=str[i]; str[j]='\0'; } main() { char str[81]; int n; printf("Input a string:"); gets(str); fun(str); printf("%s\n",str); }A.asdafaaz67B.asd af aa z67C.asdD.z67

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为#include stdio.h#include ctype.h#include string.hint fun (char *str){ int i,j=0;for(i=0;str[i]!=′ \0′;i++)if(str[i]!=′ ′)str[j++]=str[i];str[j]= ′\0′;}main(){char str[81];int n;printf("Input a string : ");gets(str);puts(str);fun(str);printf("%s\n",str);}A.asdafaaz67B.asd af aa z67C.asdD.z67

用“起泡法”对输入的10个字符排序后按从小到大的次序输出。#define N 10char str[N];main(){ int i,flag;for(flag=1;flag==1;){ scanf("%s",str);flag=0;printf("\n");}sort(___(4)___);for(i=0;iN;I++)printf("%c",str[i]);printf("\n");}sort(char str[N]){ int i,j;char t;for(j=1;jN;J++)for(i=0;(iN-J)(STR[I]!='\0');I++)if(str[i]str[i+1]){ t=str[i];____(5)____;____(6)____;}}