用C语言编写一个成语接龙的程序,要求如图,求大神帮忙,急急急急。。,
展开全部
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;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询