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

homework help please!

Name: Anonymous 2013-01-12 3:05

Why is my code not working? It's supposed to calculate 2+7 but just returns some weird number. Help?


#include <stdio.h>
#define dw unsigned long
dw t = 0; dw c = 0;
unsigned char ipl[] = {1,4,6,9};
dw mb[] = {2,7};
dw n(dw a){c++; if(c > sizeof(mb)) c=0;return a;}
dw p(dw a){c--; if((int)c < 0)c = sizeof(mb);return a;}
dw q(dw a){t=mb[c];p(a);return t;}
dw r(dw a){mb[c]=a;n(a);return a;}
dw a(dw a){return q(t+a);}
dw s(dw a){return q(t-a);}
dw m(dw a){return q(t*a);}
dw dl(dw a){return q(((dw)(t/a)));}
dw d(dw a){printf("{%u}",t);return a;}
dw z(dw a){return a;}
dw (*i[])(dw a) = {z,q,r,p,n,a,s,m,dl,d,z};
int main(int argc, char ** args){
     dw j;
     for(j=0;j<=sizeof(ipl);j++) (*i[(j % sizeof(i))])(mb[c]);
     return t;
}

Name: Anonymous 2013-01-12 3:10

Try writing that it in Java.

Name: Anonymous 2013-01-12 3:45

You did not make a proper header with your name, my name, and the date in it: Minus 10 points.
You did not name your variables descriptively: Minus 10 points.
You did not comment your code: Minus 10 points.
You did not adhere to Hungarian notation: Minus 10 points.
You did not follow proper presentation conventions: Minus 10 points.
Your code does not work: Minus 1 point.

Total: 49 Points.
Final Grade: F MINUS

Name: Anonymous 2013-01-12 4:01

>>3
And does not know how to call functions: Minus 40 points

Name: Anonymous 2013-01-12 10:50

>>4
I do used #define macro!

Name: Anonymous 2013-01-12 10:51

>>1
>>4
General absolute shittyness. Minus 9 points.

Name: Anonymous 2013-01-12 13:42

You should just Google 2 + 7, it's really good!

Name: Anonymous 2013-01-12 14:50

I always wanted to send some over-complicated code like this to the dipshits in my early CS classes. I never had the guts.

Name: Anonymous 2013-01-12 19:39

I fixed it:

main(){putchar('9');}

Name: Anonymous 2013-01-12 21:37

>>9
Undefined behavior.

Name: Anonymous 2013-01-13 1:37

Undefined Dubs.

Name: Anonymous 2013-01-13 23:06

What do you know, right there in the syllabus! "No submitting homework as a [very] poor implementation of brainfuck."

Name: Anonymous 2013-01-13 23:41

>>12
So polished ones are acceptable?

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