I'm in.
I'm in.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Vasanth and Sebastiani added.
I'm sorry, I had to go through and remove posts which gave hints towards the contest. Just so everyone knows where their posts went
Do comments count? I don't comment. The code is pretty straight forward. Should I add them in? Will I not get as high is I don't comment?
Meh, if you don't think your code needs them...
If you think I can understand the code without comments then I don't see a reason to.
Some light commenting would be nice though.
is this valid, and if so, what should be printed...
string s1 = "abcdefg";
cout << (Mid(s1, 3, 0) = "123") << endl;
C Code. C Code Run. Run Code Run... Please!
"Love is like a blackhole, you fall into it... then you get ripped apart"
>is this valid, and if so, what should be printed...
string s1 = "abcdefg";
cout << (Mid(s1, 3, 0) = "123") << endl;<
abc123defg
i think
what Mid(string, int, int) = Mid(string, int, int) does, i think, is this...
one question... should str2 be altered in this process?Code:std::string str1 = "abcdefg"; std::String str2 = "tuvwxyv"; Mid(str1, 3, 2) = Mid(str2, 3, 2); //grab the substring from str1 ("abc[de]fg") //replace it with the substring from str2 ("abc[wx]fg") //the end result, held in str1, is "abcwxfg"
If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?
Well if you want to implement assignment to const char* then yeah, that's legal.Originally posted by *ClownPimp*
is this valid, and if so, what should be printed...
string s1 = "abcdefg";
cout << (Mid(s1, 3, 0) = "123") << endl;
"abc123defg" would be printed.
Noone question... should str2 be altered in this process?
Hmmm really? I interpretted it as meaning that it would just leave it as abcdefg because the substring was of length 0.Originally posted by Eibro
Well if you want to implement assignment to const char* then yeah, that's legal.
"abc123defg" would be printed.
No
What should happen when you do this?
std::string a = "abc";
Mid( a, 3, 0 ) = "def";
or how about
std::string b = "abc";
Mid( b, 4, 0 ) = "def";
Hm, yeah, you're right. It's 3AM, what was I thinking?Originally posted by Polymorphic OOP
Hmmm really? I interpretted it as meaning that it would just leave it as abcdefg because the substring was of length 0.
What should happen when you do this?
std::string a = "abc";
Mid( a, 3, 0 ) = "def";
or how about
std::string b = "abc";
Mid( b, 4, 0 ) = "def";
so... it will only replace, at max, the length given in the first Mid call thingie? i thought it was like..
take substring from left mid, regardless of length, and put in it's place substring from right mid, regardless of length.
so...
produces a string holding "a123c"Code:string str1 = "abc"; string str2 = "123"; Mid(str1, 1, 1) = Mid(str2, 0);
If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?
I am REALLY confused now, ha.
take the substring from str1 (starting at index 1, 'b' (index 0 being 'a') and holding 1 character, just the 'b') and replace it with a boxCode:string str1 = "abc"; string str2 = "123"; Mid(str1, 1, 1) = Mid(str2, 0);
"a[ ]c"
place in that box the substring from str2 (starting at index 0, '1', and holding 3 characters, '123')
"a[123]c"
does that make any sense...? maybe this isn't how it should be done... maybe the "box" should only be able to hold how many characters it held before, meaning it only places the '1' in the "box"... BAH!
If I had a world of my own, everything would be nonsense. Nothing would be what it is, because everything would be what it isn't. And contrariwise, what it is, it wouldn't be, and what it wouldn't be, it would. You see?
The strings should grow and shrink depending on what indicies you pass.
Think of it like this, the lvalue Mid() determines what characters in the lvalue string are replaced. The rvalue Mid() determines what the characters are replaced with in the lvalue Mid().
So YES, I was right the first time.
string s1 = "abcdefg";
cout << (Mid(s1, 3, 0) = "123") << endl;
That should print "abc123defg". Because we're replacing 0 characters at position 3 in s1. If we did something like:
string s1 = "abcdefg";
string s2 = "123";
cout << (Mid(s1, 3, s2.size()) = s2) << endl;
Then "abc123g" would be printed.
count me in... (doesn't mean I'll ever get around to it )
I'd like to judge this contest.Originally posted by Eibro
Judges - 1
Eibro
[2 Slots availible - (I'm not doing this all myself!)]
Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling