int main()
{
char first[20] = {0};
char second[20] = {0};
char key[20] = {0};
//input
printf("please input first word:");
scanf("%s", first);
printf("please input second word:");
scanf("%s", second);
//begin
bool found = false;
for (int i = 0; i < 20; i ++)
{
char tmp = first[i];
if (tmp == second[0])
{
found = true;
}
if (found == true)
{
int len = 0;
for (int l = i, j = 0; l < 20, j < 20; l ++, j ++)
{
if (first[l] != 0)
{
key[j] = first[l];
len ++;
}
else
break;
}
for (int j = 0; j < len; j ++)
{
if (key[j] != second[j])
{
found = false;
memset(key, 0x00, sizeof(key)/sizeof(key[0]));
}
}
if (found)
printf("the max keyword is: %s \n", key);
else
printf("can not found the key word!! \n");
}
}
return 0;
}
解决了么,如果没有,私信我