This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / a c++ test for c++ friends
-zlx(steven);
2001-4-8
{562}
(#42125@0)
-
I can tell u the result, but could u tell me where the question is from first?
-guest:fang;
2001-4-8
(#42127@0)
-
I got it from a job agency.
-zlx(steven);
2001-4-8
(#42129@0)
-
ok, I am going to explain it for u, hold on!
-guest:fang;
2001-4-8
(#42132@0)
-
它的意思是要查找sequence from i to j 中,(查找时实际上是i to j-1,)的subsequence p to q(查找时是p to q-1) , 如果找到了子序列数,那么返回找到的位置,反之返回j. 这是一个template class. 以下代码仅供参考.Src1 search (Scr1 i, Scr1 j, Scr2 p, Scr2q);
{
Src1 tSrc1, mSrc1=i;
Src2 Src2=p;
while(mSrc1!=j){
tSrc1=mSrc1;
tSrc2=p;
while((*tSrc1==*tScr2)&&(tSrc2!=q)&&(tSrc1=q))
{++tSrc1;++tSrc2;}
if (tSrc==q)
return mSrc1;
mSrc1++;
}
return j;
}
}
}
-guest:fang;
2001-4-8
{255}
(#42145@0)
-
Sorry, 程序有些错误,更正如下.Src1 search (Src1 i, Src1 j, Src2 p, Src2q);
{
Src1 tSrc1, mSrc1=i;
Src2 tSrc2=p;
while(mSrc1!=j){
tSrc1=mSrc1;
tSrc2=p;
while((*tSrc1==*tScr2)&&(tSrc2!=q)&&(tSrc1=q))
{++tSrc1;++tSrc2;}
if (tSrc==q)
return mSrc1;
mSrc1++;
}
return j;
}
}
-guest:fang;
2001-4-9
{268}
(#42379@0)
-
怪不得我这个门外汉昨天看了半天看不懂呢。
-diao_david(LoveBeer);
2001-4-10
(#42765@0)
-
David, 那仅仅是一点笔误,无伤大碍哟!
-guest:fang;
2001-4-10
(#42766@0)
-
好精神!!!
-diao_david(LoveBeer);
2001-4-10
(#42767@0)
-
我来加之后时差就没有倒过来过,漫漫长夜,死活睡不着.
-guest:fang;
2001-4-10
(#42770@0)
-
那你索性想我这样,找个上晚班的工作,不用倒时差
-yellow(yellow);
2001-4-10
(#43155@0)
-
This program is still incorrectSrc1 search (Src1 i, Src1 j, Src2 p, Src2q);
{
Src1 tSrc1, mSrc1=i;
Src2 tSrc2=p;
while(mSrc1!=j){
tSrc1=mSrc1;
tSrc2=p;
while((*tSrc1==*tScr2)&&(tSrc2!=q)&&(tSrc1!=j))
{
++tSrc1;
++tSrc2;
}
if ((tSrc2==q)&&(*tScr1==*tScr2))
return mSrc1;
mSrc1++;
}
return j;
}
}
-liang_ll(applecore);
2001-4-10
{411}
(#43316@0)
-
哈哈,我也被考了这个题目,哈哈哈哈,我知道你是哪家公司。可惜没有人根俺合作啊,看来只有靠自己。:(
-saint(西西先生);
2001-4-9
(#42380@0)
-
I sent u email, u can check the information.
-guest:fang;
2001-4-9
(#42381@0)
-
没收到,请发sinopatriot@yahoo.com
-saint(西西先生);
2001-4-9
(#42386@0)
-
did u recieve my email?
-guest:fang;
2001-4-9
(#42409@0)
-
回答一下这个题目吧,跟那个差不多哩,让受苦受难的兄弟们共享。。。Implement the following generic Standard Library function defined in <algo>:
template <class Src>
bool equal (Src I, Src j, Src p);
// Returns true iff the subsequence i…(j-1) is the same
// as the subsquence p…(p+1)where n = i - j.
// Invariant: no elements are changed.
//---------------------------
-saint(西西先生);
2001-4-9
{310}
(#42389@0)
-
no,这个比那个要复杂些,HOLD ON!
-guest:fang;
2001-4-9
(#42407@0)
-
代码如下也许有错误不过问题不会很大.template <class Src> bool equal (Src I, Src j, Src p){
while ((i!=j) && ((*i)==(*p))) { ++i; ++p; }
if (i==j) return true;
else return false;
}
-guest:fang;
2001-4-9
{156}
(#42412@0)
-
第二道题的subsquence p..(p+1), 应该是p...(p+n).
-guest:fang;
2001-4-9
(#42415@0)
-
原题如此
-saint(西西先生);
2001-4-9
(#42431@0)
-
他写错了而且条件应该是n=j-i, 实际上这题比第一要简单因为不管p+n大于i to j还是小于我们只需从p开始查找,直到找到符合p+j-i的position就行了,这是个人意见.
-guest:fang;
2001-4-9
(#42439@0)
-
Thanks both of you. Could I contact with both of you,fang and 西西先生?My e-mail:stevenzhu2000@hotmai.com
-zlx(steven);
2001-4-9
(#42492@0)
-
我还以为您老在国内呢,这么长时间没露脸.
-guest:fang;
2001-4-9
(#42547@0)
-
我的邮件,sinopatriot@yahoo.com
-saint(西西先生);
2001-4-9
(#42557@0)
-
Steven, 在Chinasmile 的问题我在这里解答了. 关于STREAM我想你在相关书上能找到答案吧
What are the advantages and disadvantages of using a Binary Search on a tree?
What is the difference between a vector and an array?
-guest:fang;
2001-4-10
{532}
(#43094@0)