文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>华为笔试只会的第一道题...第二道不会...

华为笔试只会的第一道题...第二道不会...

时间:2010-08-23  来源:marrywindy

今下午华为上机笔试,第一年上机笔试,两道题。

我非常不满下午笔试的情形,电脑上只有VC6.0,我平常用习惯了VS,很不习惯。

还有一大系列乱七八糟的下载题目,提交,很乱...

只会第一道题,第二道不会。

第一道:删除子串,只要是原串中有相同的子串就删掉,不管有多少个。

 

代码
#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;
const char* q;
int length=strlen(sub_str);
for (p=str;*p!='\0';p++)
{
q
=sub_str;
if (*p!=*q)
{
*result=*p;
result
++;
}
else
{
const char* temp;
temp
=p;
int count=0;
do
{
count
++;
temp
++;
q
++;
}
while (*temp==*q);
if (count<length)
{
const char* t=p;
for (int i=0;i<count;i++,p++)
{
*result=*p;
result
++;
}
p
=p-1;
}
else
{
p
=temp-1;
}
}
}
if (NULL!=result)
{
return 1;
}
else
return -1;
}

int main()
{
char s[100]={'\0'};
int flag=delete_sub_str("zhaoshshhihiihihshijiezhaoshijieabcdshizaoshhssssshishishshshhihihi","shi",s);
if (flag==1)
{
printf(
"%s\n",s);
}
return 0;
}

反正上机的时候,没有在自己电脑写的爽...

还给了啥鸟模板...靠....

一塌糊涂...
挂了....

 

相关阅读 更多 +
排行榜 更多 +
幸存者的命运

幸存者的命运

飞行射击 下载
精英战区3d

精英战区3d

飞行射击 下载
货运猎人

货运猎人

飞行射击 下载