Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Pi

Name: Anonymous 2010-06-03 14:55

int a=10000,b,c=2800,d,e,f[2801],g;main(){for(;b-c;)f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)for(b=c;d+=f[b]*a,
f[b]=d%--g,d/=g--,--b;d*=b);}

Name: Anonymous 2010-06-03 22:01

Learn to indent your code.

Name: Anonymous 2010-06-04 1:33

>>2
THE FORCED INDENTATION OF CODE!?

Name: Anonymous 2010-06-04 2:26

Technical works are conducted. Site will be again accessible soon.

Name: Anonymous 2010-06-04 19:46

That's a lot of undefined behavior you're relying on, there. That's even ignoring the things that are explicitly wrong.

Name: Anonymous 2010-06-05 3:53

>>5
like what?

Name: Anonymous 2010-06-05 10:22

int a = 10000, b, c=2800, d, e, f[2801], g;
main()
{
   for(; b - c; )
   {
      f[b++] = a/5;
   }
   for(; d = 0, g = c*2 ; c -= 14, printf("%.4d",e+d/a),e=d%a)
   {
      for(b = c; d += f[b]*a, f[b] = d%--g, d /= g--, --b; d *= b);
   }
}


>>6
For starters, four of your variables remain uninitialized (only SOME systems accept that) and all of your loops are broken in some way.  For your first loop, you are probably hoping that b is auto-initialized to 0 and that the loop will terminate when b - c is equal to 2800 - 2800; in practice, b will be initialized to whatever junk data is stored at the memory location allocated for b and should not be trusted.  It could be a negative number and that would try to access array data at negative indices.  The same goes for all uninitialized variables.

For your second loop, it lacks a proper conditional statement and statements that should have been placed in the initialization block are in the conditional block.

The third loop also lacks a test condition statement.  I'm going to make a guess but based on what it looks like one of the conditional statements should be whether b is less than zero.  This is just a shot in the dark:

for(b = c; b >= 0 && ...; d += f[b]*a, f[b] = d%--g, d /= g--, --b, d *= b);

Name: Anonymous 2010-06-05 13:14

I worked for a software company last Summer, and my mentor pointed out a part in Kernighan & Ritchie where it said that "experienced" programmers had no need for separating out "f[b] = X" from "b++". It's bollocks, since today any number of morons could be needing to understand what your code does and shortcuts like that merely obscure the meaning.

Name: Anonymous 2010-06-05 16:32

>>7
None of his loops lack proper conditional statements. l2C.
It's true that he's depending on auto-initialisation to 0, which isn't guaranteed at all. However,

b will be initialized to whatever junk data is stored at the memory location allocated
Memory is cleared by the OS before it is allocated to applications in every OS that does memory protection (and most that don't). I know it's a popular misconception that uninitialised variables will contain whatever happened to be there from the last time an application used that bit of memory, but that's total toss.

Anyway, the main problems are lack of initialisation and a malformed main declaration. Sensible compilers and platforms would reject the code altogether, but it will probably do what he expects it to on most.

Name: Anonymous 2010-06-05 21:39

>>9
This isn't /prog/ but I am curious about that.  How does
d = 0, g = c*2
count as the test condition for the loop
for( ; d = 0, g = c*2 ; c -= 14, printf("%.4d",e+d/a),e=d%a)
?

Name: Anonymous 2010-06-06 13:32

>>7,9
b is guaranteed to be initialized to zero (C99 6.7.8p10). Static storage duration is different from automatic storage duration.

>>10
The result of the comma operator has the type and value of its right operand, and conditions are defined to pass if they compare unequal to 0. So d = 0, g = c*2 first assigns d, then assigns g, then executes the loop body if the new g value is nonzero.

Name: Anonymous 2010-06-06 15:43

the mystery continues...

Name: Anonymous 2010-06-10 0:28

>>12
...in search of the clitoris.

:/

Don't change these.
Name: Email:
Entire Thread Thread List