- int main(){
- // 求两个字符串的公共最大字符串,并输出长度 和 公共字符串
- char ch1[] = "lanoukeji";
- char ch2[] = "abcoukefuntay";
- char ch3[20] = {0};
- int count = 0;
-
- for (int i = 0; i < strlen(ch2) - 1; i++) {
- if (ch1[i] == ch2[i])
- {
- count += 1;
-
- ch3[i] = ch2[i];
-
- }
- }
- printf("lenth = %d + 内容是: %s",count, ch3);
-
-
-
-
- return 0;
- }
复制代码 |
|