Re: subset function for string in c++




Randy Howard wrote:
> August Karlstrom wrote
> (in article <eLC_e.34873$d5.190040@xxxxxxxxxxxxxxx>):
>
> > puzzlecracker wrote:
> >> basically, I need to find out wether charecters in string a are subset
> >> of string b..
> >>
> >>
> >> example
> >>
> >>
> >> a: rx b:rwx
> >> that shall return true.
> >>
> >
> > As this group is language independent i chose to write an implementation
> > in Oberon:
> >
> > PROCEDURE Subset(a, b: ARRAY OF CHAR): BOOLEAN;
> > VAR j, k: LONGINT;
> > BEGIN
> > j := 0;
> > WHILE a[j] # 0X DO
> > k := 0;
> > WHILE (b[k] # 0X) & (b[k] # a[j]) DO INC(k) END;
> > IF b[k] = 0X THEN RETURN FALSE END;
> > INC(j)
> > END;
> > RETURN TRUE
> > END Subset;
> >
> >
>
> Wow. Ben's version sure seems a lot clearer. :-)
>
> I'm having pascal flashbacks, make it stop.
>
> --
> Randy Howard (2reply remove FOOBAR)


All above is NOT- again NOT NOT NOT NOT C++...


the c++ way is - are you all still with me (pay attention... NOW)?

string a; // that is right, here we declare a string and named it a
string b; // same as above

// give some values to a and b...like

a="why cannot I still write c++ code";
b="c++ code";

a.find_first_not_of(b);

That is what we call sleek C++ code in the UNITED STATES OF AMERICA!

Now, re-read it 100 times and admit that above posts are flawed,
erronous, completely bizzare and ultimately useless.

we rule,

puzzlecracker.

.



Relevant Pages