首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

往哪网 2014.9.25 笔试题

2013-09-28 
去哪网 2014.9.25 笔试题#include stdio.h#include stdlib.h#include string.hchar *overlay_fun(ch

去哪网 2014.9.25 笔试题

#include <stdio.h>#include <stdlib.h>#include <string.h>char *overlay_fun(char *str, char *overlay, int start, int end){  char *copy = malloc(strlen(str)*sizeof(char));  int i = 0;  int j = 0;  if(strlen(str) == 0)        return NULL;  if(start < 0)      start = 0;  if(end < 0)      end = 0;  if(start > end)     {       int tmp;       tmp = start;       start = end;       end = tmp;      }  if(start > strlen(str))     start = strlen(str);  if(end > strlen(str))    end = strlen(str);for(i = 0; i < start; i++)  {    copy[i] = str[i];  }  copy[i] = '\0';  while(overlay[j] != '\0')  {    copy[i] = overlay[j];    j++;    i++;  }  while(str[end] != '\0')  {    copy[i] = str[end];    end++;    i++;  }  str = copy;  return copy;}



热点排行