谁能把一下c++代码转为Delphi代码..150分..来顶的都有分了.. ( 积分: 150 )

  • 主题发起人 主题发起人 immediately
  • 开始时间 开始时间
I

immediately

Unregistered / Unconfirmed
GUEST, unregistred user!
void ClipSample(CString strSrcFile,CString strSampleFile)
{
//ºÏ³Éºó£¬»¹Òª¶ÔÎļþ½øÐд¦Àí£¬ÒÔɾ³ý±»Ëæ»ú²åÈëµÄ"±±¾©½Ýͨ..."Ñù±¾¡£
CFile file;
if(!file.Open(strSrcFile,CFile::modeReadWrite))
{
return;
}
CFile fileSample;
fileSample.Open(strSampleFile,CFile::modeRead);
size_t size=file.GetLength();
char *cSrc=new char[size+16];
memse2t(cSrc,0,sizeof(cSrc));
size=fileSample.GetLength();
char* cSample=new char[size+16];
memset(cSample,0,sizeof(cSample));
file.Read(cSrc,file.GetLength());
fileSample.Read(cSample,fileSample.GetLength());
char* p1;
char* p2;
p1=cSrc;
p2=cSample;
int total_count=file.GetLength();
int sample_count=fileSample.GetLength();
BOOL bFind=FALSE;
while(true)//Èç¹ûʣϵÄÊý¾ÝÒѲ»×ãÒÔ¹¹³ÉÒ»¸öÑù±¾£¬¾ÍÎÞÐèÔٱȽÏÁË¡£
{
p2=cSample;//¸´Î»¡£
if(*p1==*p2)
{
p1++;
p2++;
while(*p1==*p2)
{
p1++;
p2++;
if(p1-cSrc>=total_count)
break;
if(p2-cSample>=sample_count)
break;
}
}
if(p2-cSample>=sample_count)//˵Ã÷ÕÒµ½Á˸ÃÄ¿±ê´®¡£
{
//½«´ÓÔ­´®ÖÐÌÞ³ý¸ÃÄ¿±ê´®¡£
//Ñù±¾µÄβ²¿°éËæ×Å´óÁ¿µÄ¾²Òô(³¬¹ý6K)£¬²¢Î´±È½Ï£¬Ò²ÒªÉ¾³ýÕâЩ¾²Òô¡£
memmove(p1-sample_count,p1+6*1024,total_count-(p1-cSrc)-6*1024);
p1=p1-sample_count;
total_count-=sample_count;
total_count-=6*1024;
bFind=TRUE;//ÕÒµ½¡£
}
else
{
//δÕÒµ½¡£
p1++;
if(p1-cSrc>=total_count)
break;
}
}
if(bFind)
{
file.Close();
file.Open(strSrcFile,CFile::modeCreate|CFile::modeReadWrite);
file.Write(cSrc,total_count);
}
file.Close();
fileSample.Close();
delete cSample;
delete cSrc;
}
//乱码为注释.
 
void ClipSample(CString strSrcFile,CString strSampleFile)
{
//ºÏ³Éºó£¬»¹Òª¶ÔÎļþ½øÐд¦Àí£¬ÒÔɾ³ý±»Ëæ»ú²åÈëµÄ"±±¾©½Ýͨ..."Ñù±¾¡£
CFile file;
if(!file.Open(strSrcFile,CFile::modeReadWrite))
{
return;
}
CFile fileSample;
fileSample.Open(strSampleFile,CFile::modeRead);
size_t size=file.GetLength();
char *cSrc=new char[size+16];
memse2t(cSrc,0,sizeof(cSrc));
size=fileSample.GetLength();
char* cSample=new char[size+16];
memset(cSample,0,sizeof(cSample));
file.Read(cSrc,file.GetLength());
fileSample.Read(cSample,fileSample.GetLength());
char* p1;
char* p2;
p1=cSrc;
p2=cSample;
int total_count=file.GetLength();
int sample_count=fileSample.GetLength();
BOOL bFind=FALSE;
while(true)//Èç¹ûʣϵÄÊý¾ÝÒѲ»×ãÒÔ¹¹³ÉÒ»¸öÑù±¾£¬¾ÍÎÞÐèÔٱȽÏÁË¡£
{
p2=cSample;//¸´Î»¡£
if(*p1==*p2)
{
p1++;
p2++;
while(*p1==*p2)
{
p1++;
p2++;
if(p1-cSrc>=total_count)
break;
if(p2-cSample>=sample_count)
break;
}
}
if(p2-cSample>=sample_count)//˵Ã÷ÕÒµ½Á˸ÃÄ¿±ê´®¡£
{
//½«´ÓÔ­´®ÖÐÌÞ³ý¸ÃÄ¿±ê´®¡£
//Ñù±¾µÄβ²¿°éËæ×Å´óÁ¿µÄ¾²Òô(³¬¹ý6K)£¬²¢Î´±È½Ï£¬Ò²ÒªÉ¾³ýÕâЩ¾²Òô¡£
memmove(p1-sample_count,p1+6*1024,total_count-(p1-cSrc)-6*1024);
p1=p1-sample_count;
total_count-=sample_count;
total_count-=6*1024;
bFind=TRUE;//ÕÒµ½¡£
}
else
{
//δÕÒµ½¡£
p1++;
if(p1-cSrc>=total_count)
break;
}
}
if(bFind)
{
file.Close();
file.Open(strSrcFile,CFile::modeCreate|CFile::modeReadWrite);
file.Write(cSrc,total_count);
}
file.Close();
fileSample.Close();
delete cSample;
delete cSrc;
}
//乱码为注释.
 
没人看..分数太少???自己顶
 
不是很难,只是代码有点多。
我5分钟内搞不定。
 
下午1点之前搞定..再加50分...
 
如果你来回答简单之类的不着边际的话...拜托就不要回复了...我要的是把上面转为delphi代码的答案..谢谢合作.
 
今天天气不行,
阴风阵阵~~~~
看来是没什么好事了。
 
....................没人回答
 
版主。。。我想结束问题啊。可是也没人给回答。。。分数能不能收回啊。。。。
明天把我的代码贴上来。
 
没人进来接收分数吗
发分了..
var
p1,p2 ,tmpP : pByte ;
tp1,tp2 :pByte;//^Byte ;
SavePos : integer ;
FindPos : integer ;
a,b,c : TMemoryStream ;
i ,j: integer ;
bFind :boolean ;
tCount,sCount : int64 ;
begin
bFind := false ;
a := TMemoryStream.Create ;
b := TMemoryStream.Create ;
c := TMemoryStream.Create ;
try
a.LoadFromFile(f1);
b.LoadFromFile(f2);
c.SetSize(a.Size);
tCount := a.Size ;
sCount := b.Size ;
tp1 := a.Memory ;
tp2 := b.Memory ;
p1 := a.Memory ;
if a.Size < b.Size then
c.CopyFrom(a,a.Size)
else
for i := 0 to a.Size -1 do
begin
p2 := b.Memory ;
if (p1^ =p2^) then
//&Egrave;&ccedil;&sup1;&ucirc;±&Egrave;&frac12;&Iuml;&micro;&Auml;×&Ouml;&frac12;&Uacute;&Iuml;à&micro;&Egrave;,&raquo;&sup1;&Ograve;&ordf;±&Egrave;&frac12;&Iuml;&Aacute;&not;&ETH;&oslash;&micro;&Auml;×&Ouml;&frac12;&Uacute;&Ecirc;&Ccedil;·&ntilde;&Iuml;à&micro;&Egrave;,&acute;ó&ETH;&iexcl;&sup2;&icirc;&sup2;&raquo;&para;à&Ecirc;&Ccedil;&Ntilde;ù±&frac34;&micro;&Auml;&acute;ó&ETH;&iexcl;
begin
tmpP := p1 ;
SavePos := a.Position ;//±&pound;&acute;&aelig;&micro;&Uacute;&Ograve;&raquo;&Iuml;à&micro;&Egrave;×&Ouml;&frac12;&Uacute;&micro;&Auml;&Icirc;&raquo;&Ouml;&Atilde;,&Ograve;ò&Icirc;&ordf;&sup2;&raquo;&Auml;&Uuml;±&pound;&Ouml;¤&Aacute;&not;&ETH;&oslash;&micro;&Auml;×&Ouml;&frac12;&Uacute;&para;&frac14;&Iuml;à&micro;&Egrave;
Inc(p1);
Inc(p2);
a.Seek(SavePos + 1,soFrombegin
ning);
while (p1^=p2^) do
//&frac14;&Igrave;&ETH;&oslash;±&Egrave;&frac12;&Iuml;&ordm;ó&ETH;&oslash;×&Ouml;&frac12;&Uacute;
begin
Inc(p1);
Inc(p2);
a.Seek(a.Position+ 1,soFrombegin
ning);
//&Egrave;&ccedil;&sup1;&ucirc;&Otilde;&Ograve;&micro;&frac12;&AElig;&yen;&Aring;&auml;&Euml;ù&Oacute;&ETH;&micro;&Auml;&Ntilde;ù±&frac34;×&Ouml;&frac12;&Uacute;,&Ocirc;ò&Igrave;&oslash;&sup3;&ouml;&Ntilde;&shy;&raquo;·
if ((LongInt(p1)-LongInt(tp1))>= tCount )or
((LongInt(p2)-LongInt(tp2))>= sCount ) then
begin
bFind := true ;// &Otilde;&Ograve;&micro;&frac12;
FindPos := a.Position ;
//&Iacute;&not;&Ecirc;±&frac14;&Ccedil;&Ocirc;&Oslash;&micro;±&Ccedil;°a&micro;&Auml;&Icirc;&raquo;&Ouml;&Atilde;
break ;
end ;
end;
//&Egrave;&ccedil;&sup1;&ucirc;&Atilde;&raquo;&Oacute;&ETH;&Otilde;&Ograve;&micro;&frac12;,&Ocirc;òp1&micro;&Auml;&Ouml;&cedil;&Otilde;&euml;&Ograve;&ordf;&raquo;&Oslash;&Iacute;&Euml;&micro;&frac12;&Ocirc;&shy;&Agrave;&acute;&micro;&Uacute;&Ograve;&raquo;&acute;&Icirc;&Iuml;à&micro;&Egrave;&micro;&Auml;&Icirc;&raquo;&Ouml;&Atilde;
//&Iacute;&not;&Ecirc;±&Ograve;&ordf;&acute;&Oacute;&micro;&Uacute;&Ograve;&raquo;&acute;&Icirc;&Iuml;à&micro;&Egrave;&micro;&Auml;&micro;&frac12;&sup2;&raquo;&Iuml;à&micro;&Egrave;&micro;&Auml;&Auml;&Ccedil;&para;&Icirc;×&Ouml;&frac12;&Uacute;&ETH;&acute;&Egrave;&euml;&micro;&frac12;c&Icirc;&Auml;&frac14;&thorn;&Ouml;&ETH;
if not bFind then
begin
p1 := tmpP ;
//&raquo;&Oslash;&Iacute;&Euml;p1&Ouml;&cedil;&Otilde;&euml;
Inc(p1);
for j := SavePos to a.Position -1 do
//(LongInt(p1)-LongInt(tmpP)) do
begin
c.Write(tmpP^,1) ;
Inc(tmpP);
end;
end;
end
else
begin
//&sup2;&raquo;&Iuml;à&micro;&Egrave;,&Ocirc;ò&ETH;&acute;&Egrave;&euml;c&Icirc;&Auml;&frac14;&thorn;&Ouml;&ETH;
c.Write(p1^,1);
Inc(p1);
a.Seek(i + 1,soFrombegin
ning) ;
end;
end;
//&Oacute;&Eacute;&Oacute;&Uacute;&ordm;&Iuml;&sup3;&Eacute;&micro;&Auml;&Oacute;&iuml;&Ograve;&ocirc;&Icirc;&Auml;&frac14;&thorn;&Icirc;&sup2;&sup2;&iquest;&raquo;&sup1;&Oacute;&ETH;&Ocirc;&euml;&Ograve;&ocirc;,&acute;ó&ETH;&iexcl;32k--64k,&Euml;ù&Ograve;&Ocirc;&Ograve;&ordf;&frac12;&Oslash;&micro;&ocirc;
c.SetSize(c.Size- 1024*32);
c.Position := 0 ;
c.SaveToFile(f7);
finally
a.Free ;
b.Free ;
c.Free ;
end;
end;

乱码没办法..
f1为源文件..f2为样本文件..f3为删除的东西
 
dingdingdingdingdingdingding
 
好心帮你顶,望你来点分
 
有分我来顶
 
顶!!!!!!!!!!!!!!!!!11
 
GOOD!GOOD!GOOD!
 
发分了。。以后提问题前得先查资料。。
 
后退
顶部