![]() |
how short can you make this
what things can one shorten in this area program
:
#include <iostream.h> |
newlines... yep, they've got to go... Seriously though, shorter code is not necessarily better code. Often it's the opposite. Obfuscated code is only good for confusing people (hence the name).
By the way, you're using a deprecated header. Use #include<iostream> and look up namespace std. |
uhm... none that I can see.....
|
There are a couple of ways to shorten this without making it any less readable:
:
#include <iostream>Seriously though, I don't know why you'd bother. DaWei has a link to an excellent article on optimisation and how to determine whether it's necessary - if I wasn't so sleepy, I'd point you to it. I think it's in his signature. More important would be error-checking. |
how do i look up namespace std...?
instead of #include<iostream.h> is it #include<iostream> using namespace std; just like that or what exactly (with right punctuation and spelling) is it? |
(without offense): [b]how do i look up namespace std...?[b] Aren't you supposed to be some super asain? genius? I mean I have asked some pretty (IMO) stupid questions but you just blew me out of the water!
using the following is stating that the entire program is using the standard namespace. :
using namespace std;without using the above use the following to state the namespace in a single instance :
std::cout << "(IMO) this one is better" << std::endl; |
ouch...
|
you could optimize a bit within the inline keyword...
:
inline int area(unsigned short int x, unsigned short int y) |
Kilo, why did you make a reference to him being Asian? That has nothing to do with the OP's question.
I think Ooble about shortened it up with it still being readable. Of course, you could still do this: :
#include <iostream>That would be an awful way to put it, though. |
Quote:
but still, thanks especially for the second way fo defining without doing it at the beginningm thats what ooble did and it confused me but now i get it ps- i am a genius, just not at programming |
| All times are GMT -5. The time now is 8:05 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC