#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int count = 0;
char Longest_no_again(char str[],int size)
{
char p = str;
char* q = str;
while (*q)
{
p = &str[0];
while (p < q)
{
if (p == q)
return q;
p++;
}
q++;
count++;
}
return NULL;
}
int main(void)
{
char str[100] = " ";
char q = str;
gets_s(str);
int size = strlen(str);
charp=Longest_no_again(str,size);
if (p != NULL)
{
while (q < p)
{
printf("%c", *q);
q++;
}
printf("\n%d\n", count);
}
else
{
printf(“无重复\n”);
printf("%d\n", size);
}
system(“pause”);
return 0;
}
输出一个字符串的最长子串
最新推荐文章于 2023-11-18 22:36:26 发布