Hey guys what do you think of my highly optimized code :^)?

Hey guys what do you think of my highly optimized code :^)?

>Not using assembly
Come back when you're an actual programmer, kid.

I actually kind of like cin/cout, it's a guaranteed indicator that the poster is a first semester CS student and doesn't know shit.

What's better, passing in as an argument? Never really touched C++.

>College
>Implying

I'm fully convinced cin/cout was added to C++ to make it easier to do hello world.

> optimized

Streams are very inefficient senpai.

As opposed to what? printf? Give me a break.

Well, at least you're using CodeBlocks.

>no indentation
D R O P P E D

That's what makes it optimized desu

>no indentation
Unreadable.
>using a Windows IDE and probably a Windows compiler
>doesn't follow GNU standards
I barfed

the compiler doesn't see whitespace

What's a GNU standard?

Indentations and comments are stripped by the compiler...

rate
function isntprime(argument) {
while (true) if (argument % Math.floor(Math.random()*100) === 0) break
return true
}

Example of the GNU standard:
int
main (int argc, char *argv[])
{
struct gizmo foo;

fetch_gizmo (&foo, argv[1]);

check:
if (foo.type == MOOMIN)
puts ("It's a moomin.");
else if (foo.bar < GIZMO_SNUFKIN_THRESHOLD / 2
|| (strcmp (foo.class_name, "snufkin") == 0)
&& foo.bar < GIZMO_SNUFKIN_THRESHOLD)
puts ("It's a snufkin.");
else
{
char *barney; /* Pointer to the first character after
the last slash in the file name. */
int wilma; /* Approximate size of the universe. */
int fred; /* Max value of the `bar' field. */

do
{
frobnicate (&foo, GIZMO_SNUFKIN_THRESHOLD,
&barney, &wilma, &fred);
twiddle (&foo, barney, wilma + fred);
}
while (foo.bar >= GIZMO_SNUFKIN_THRESHOLD);

store_size (wilma);

goto check;
}

return 0;
}

return isPrime(input);

isPrime() is left as an exercise for the reader.

But it makes the source code smaller

who cares?
if you wanna compress text just tar and gzip it

Yes, we all get this. Stop being a smartass.

You need to be 18 years old to post here.

This is the worst kind of person

Tiers of C++ programmers:

>Newbie tier: thinks Disillusioned tier: le operator overloading is bad meme, le c++ is overcomplicated meme
>Ascended tier: found his inner peace, embraces the iostream

>t. someone who has never written C++ for a living

Kill yourself, you dumb fucking shit stain.

Cs101

Step it up.
|_ {bowl $~}
::
++ prim
|= x/@
=+ i=2
|- ^- ?
?: =(x i) &
?: =(0 (mod x i)) |
$(i +(i))
::
++ poke-noun
|= a/@
~& ?:((prim a) [a %is-prime] [a %not-prime])
[~ +>.$]
--

Have you been following me around recently?

WTF are you supposed to do for "solve this puzzle" type command line shit???

I'm gonna hurt you

for i:=1 to trunc(sqrt(x)) you retarded faggot

>abusing namespace std;

printf

non-descriptive, cryptic code != Optimized code

I took the bait

OP you only have to try factors up the square root of x

>using the smiley with a carat nose

step up your game nigga and use scanf/printf

just fwrite to stdout

No sieve of eratosthenes. Kill yourself.

Why?

>not putting it all on a single line
3/10, see me after class

iostream is way slower than cstdio.
but, the compiler replaces your brain when you're using iostream, because it's using type safety.

You should only loop until sqrt(x), all the other divisors can be obtained from x/i, where i is an integer smaller than sqrt(x).
For example:
Let's obtain the divisors of 20
1 2 4 5 10 20

Sqrt(20) is somewhere between 4 and 5.

20 is 20/1
10 is 20/2
And 5 is 20/4

So it's useless to check numbers above sqrt(x). Try it out!

>"Enter a Positive Integer"
>1

>highly optimized
>not using inline functions
>O(n) prime checker
>iostream and not write()
>unportable system() bullshit because you're too stupid to run your shit properly
>implying more chars = more slow
unreadable dogshit, 2/10

>isPrime(1)
>skips the for loop because 2 > 1
>returns true
It works you stupid shit

What does no formatting have to do with optimization?

0/8 total piece of crap

>optimizing for disk space
WHAT YEAR IS IT?

1 is not prime

shut up, we are glad it finally works

>i"""highly""" optimized
Agh

Wew hoon

You can also first check 2, then start the loop at 3 and increment by two each time - if the number is divisible by any even number, it is divisible by 2 anyway.