www.ctrt.net > 设有两个字符串A和B,要求将A,B串对应字符中的较...

设有两个字符串A和B,要求将A,B串对应字符中的较...

#include #include void main(){ char a[80],b[80],c[80]; int lena,lenb,i,j,k; gets(a); gets(b); lena=strlen(a); lenb=strlen(b); i=j=k=0; while (i

已经改好了,给: #include #include void main() { int k=0; char a[80]={NULL},b[80]={NULL},c[80]={NULL},*p=NULL,*q=NULL; //注意数组初始化的方式 p=a; q=b; printf("请向数组a中存放字符串:");gets(p); printf("请向数组b中存放字符串:"...

改几处: while(*q)改为while(q && p) //不知p、q谁的长度最短,直接判断指针,指向结束符时为假 if(*p) 改为if(p) //类似 ??填 strcat(c,q)

#include #include #include char *my_delsub(char *str,char *sub) { char *p,*str2; char *t; int i=0; t=(char *)malloc(strlen(str)); str2=str; p=sub; while(*str2) { while(*p) { if(*p==*str2) break; p++; } if(*p=='\0') { t[i]=*str2...

#include #include #include const char *max(const char *x);int main(void){ char string1[1024] = {0}; //字符串1; char string2[1024] = {0}; //字符串2; printf("Input string1:"); gets(string1); //输入串1; printf("Input string2:"); g...

#include int main(void) { char a[128], b[128]; char *p = a; int i; printf("请输入字符串a:"); gets(a); printf("请输入字符串b:"); gets(b); while (*p) p++; for (i = 0; i < 5; i++) p[i] = b[i]; p[++i] = '\0'; printf("%s\n", a); ret...

char *toc(const char *a, const char *b, char *c) { char *pc = c; if (a == NULL || b == NULL || c == NULL) return c; while(*a != '\0' && *b != '\0') { *c = (*a > *b) ? *a : *b; a++; b++; c++; } *c = '\0'; return pc; }

#include #include int main(void){char a[10]="1234";char b[5]="5678";char c[10] ={0};strcat(a,b);strcpy(c,a);return 0;}

String a = "1234567"; String b = "abcdefg"; if (b.length() > 5) { a = a.concat(b.substring(0, 5)); } else { a = a.concat(b); } 输入就算了

#include void strcat(char *s1,char *s2,int n) { char *p = s1; char *q = s2; while(*p) p++; while((q < s2 + n) && (*q)) *p++ = *q++; *p = '\0'; } int main() { char sa[50],sb[50]; printf("sa = "); gets(sa); printf("sb = "); gets(...

网站地图

All rights reserved Powered by www.ctrt.net

copyright ©right 2010-2021。
www.ctrt.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com