Strangely, it is he lack of spaces around *= in ans*=a that triggers me the most.
OP, move one opening bracket to the next line and remove one space from one side of one of the binary operations anywhere and you have a true masterpiece.
Yeah, there can be conflicts. I only know c++ basics so please correct me if I am wrong.
If you have two namespace, for simplicity 'a' and 'b'. If both of them have a 'string' class in them you would usually say a::string... or b::string... If you are using a namespace, for this example 'a', c++ reads everything as a::. If you want a string you then impulsive say string, but if you wanted to do b::string, that can leave some nasty bugs.
I also have never seen it happen, but that is what my teacher said. Seeing the upvotes I think I am right. I currently have to use c++ for the optimization project of a simulation. It is interesting in theory, but man do I hate it... I know all languages have their flaws, but the unreadable error messages really make me want to make the Geneva Conventions a checklist...
Yes. Besides the other answer about using namespace vs. using individual symbols, you also want your using statements to be within curlies so they won't spill into other files and clobber the names of local variables.
The worst part of this for me is the fact that his factorial function will only be fed negative integers, and so just always returns ‘1’
Edit: ok the entire thing hinges off of that sin function, it’s designed to be 0 when S is odd - I get the feeling this is just for show, not something someone actually thought was a good idea
The 1/i scares me because it is int/int and it is computed before converting to float in which case, for i>1, it is just 0. Please correct me if I am wrong.
In a nutshell it means it’s guaranteed to be (at least) a 64 bit data type (int or pointer) regardless of compiler and cpu architecture. A lonely long maybe 32 bit or 64 bit depending on the implementation (even on 64 bit systems) and whether it’s an integer or a pointer.
If this is real code it seems it's written by someone that's worked with mathematics all their life in a bunker in the woods and then at the age of 97 needs to actually use their mathematical knowledge.
138
u/PicksNits Dec 19 '21
This is some prime bad code but
s *= 1feels just awful even in this monstrosity. Great job!47
u/BadSlime Dec 18 '21
This is hilarious
42
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 18 '21
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
41
u/GLIBG10B 🐧 Gentoo salesman🐧 Dec 19 '21
29
u/alexppetrov Dec 19 '21
When the prof says they will check for plagiarism on the exam
28
u/AJohnnyTruant Dec 19 '21
s*=1
Dear god
National Suicide Prevention Hotline: 1-800-273-8255
26
u/Legend_Zector Dec 19 '21 edited Dec 19 '21
The worst part of this for me is the fact that his factorial function will only be fed negative integers, and so just always returns ‘1’
Edit: ok the entire thing hinges off of that sin function, it’s designed to be 0 when S is odd - I get the feeling this is just for show, not something someone actually thought was a good idea
4
u/Shai_the_Lynx Dec 19 '21
I did see a lot of people forgeting modulo exists while I was in college.
1
u/[deleted] Dec 19 '21
What's the color theme called? Looks fabulous :)
1
u/BridgesRectify Dec 27 '21
The 1/i scares me because it is int/int and it is computed before converting to float in which case, for i>1, it is just 0. Please correct me if I am wrong.
5
u/[deleted] Dec 19 '21
What does the
long longmeans ?1
u/HerrNilsen- Dec 19 '21
Imagen s & 1
1
u/MrPythonman12345 Dec 19 '21
what does this code even do?
1
u/fugogugo Dec 19 '21
what even is riemann and fact?
1
u/sliversniper Dec 26 '21
This has to be intentional, or wanted to try f with compiler,
1
u/trollsmurf Dec 26 '21
If this is real code it seems it's written by someone that's worked with mathematics all their life in a bunker in the woods and then at the age of 97 needs to actually use their mathematical knowledge.
0
u/[deleted] Dec 19 '21
[deleted] — view deleted comment