淄博网络营销网站,软件开发培训机构多少钱,网络活动策划方案,appcan wordpress1、题目 *判断参数是否与一个关键字列表任何单词匹配 *并返回匹配的索引值,如果没有找到返回-1 2、代码实现 #include stdio.h
#include stdlib.h
#include string.h/***判断参数是否与一个关键字列表任何单词匹配*并返回匹配的索引值,…1、题目
*判断参数是否与一个关键字列表任何单词匹配 *并返回匹配的索引值,如果没有找到返回-1 2、代码实现 #include stdio.h
#include stdlib.h
#include string.h/***判断参数是否与一个关键字列表任何单词匹配*并返回匹配的索引值,如果没有找到返回-1**/int lookup_keyword(const char *const desired,
const char *keyword[], int const size)
{const char **p;for (p = keyword; p keyword + size; p++){if (strcmp(desired, *p) == 0){return p - keyword;}}return -1;
}int main()
{const char *keyword[] = {"chen", "gong", "yu", "cai"};const char *const desired = "yu";int size = sizeof(keyword) / sizeof(keyword[0]);printf("size is %d\n", size);int result = lookup_keyword(des