以下程序的输出结果是________。#include#include int f(char c, char *s){ int m,n,h; for(n=0,h=strlen(s);n<=h;){m=(n+h)/2;if(cs[m]) n=m+1;else return m; } return -1; } int main(void){ printf("%d ",f('g',"abdgkmxy")); printf("%d \n",f('C',"BQMAXYZOTE")); return 0;}
查看答案
下列程序中的函数strcpy2()实现字符串两次复制,即将t所指字符串复制两次到s所指内存空间中,合并形成一个新字符串。例如:若t所指字符串为“efgh”,调用strcpy2后,s所指字符串为“efghefgh”。请填空。#include#include void strcpy2(char *s,char *t){ char *p=t; while(*s++=*t++); s=_____; while(_____=*p++);}int main(void){ char str1[100]="abcd",str2[]="efgh"; strcpy2(str1,str2); printf("%s\n",str1); return 0;}
下面程序运行时如果从键盘上输入字符串“qwerty”和“abcd”,则程序的输出结果是________。#include#include int strle(char a[],char b[]){ int num=0,n=0; while(*(a+num)!='\0') num++; while(b[n]){ *(a+num)=b[n]; num++; n++;} return (num);}int main(void){ char str1[81],str2[81],*p1=str1,*p2=str2; gets(p1); gets(p2); printf("%d\n",strle(p1,p2)); return 0;}
下面程序运行后输入g,其后的输出为_______。#include#includeint main(void){ int i; char s[]="programming!",ch; ch=getchar();printf("%d\n",sizeof(s));for(i=0;i
下列程序的输出结果是_______。char *ss(char *s){ char *p,t; p=s+1; t=*s; while(*p) {*(p-1)=*p;p++; } *(p-1)=t; return s;}int main(void){ char *p,str[10]="abcdefgh"; p=ss(str); printf("%s\n",p);}