华为校园招聘机考试题大全.docxVIP

  • 23
  • 0
  • 约3.14万字
  • 约 29页
  • 2019-01-02 发布于广东
  • 举报
2012 华为校园招聘机考试题总结(厦门大学) 1、删除子串,只要是原串中有相同的子串就删掉,不管有多少个,返回子串个数。 #include stdio.h #include stdlib.h #include assert.h #include string.h int delete_sub_str(const char *str,const char *sub_str,char *result) { assert(str != NULL sub_str != NULL); const char *p,*q; char *t,*temp; p = str; q = sub_str; t = result; int n,count = 0; n = strlen(q); tmep = (char *)malloc(n+1); memset(temp,0x00,n+1); while(*p) { memcpy(temp,p,n); if(strcmp(temp,q) == 0 ) { count++; memset(temp;0x00,n+1); p = p + n; } else { *t = *p; p++; t++; memset(temp,0x00,n+1); } } free(temp); return count; } int main() { char s[100]

文档评论(0)

1亿VIP精品文档

相关文档