bad.c

#include <stdio.h>
main(t,_,a)
char
*
a;
{
	return!

0<t?
t<3?

main(-79,-13,a+
main(-87,1-_,
main(-86, 0, a+1 )


+a)):

1,
t<_?
main(t+1, _, a )
:3,

main ( -94, -27+t, a )
&&t == 2 ?_
<13 ?

main ( 2, _+1, "%s %d %d\n" )

:9:16:
t<0?
t<-72?
main( _, t,
"@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#;\
#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l q#'+d'K#!/+k#;\
q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw' i;# ){nl]!/n{n#'; \
r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#\
\
n'wk nw' iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c ;;\
{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;\
#'rdq#w! nr'/ ') }+}{rl#'{n' ')# }'+}##(!!/")
:
t<-50?
_==*a ?
putchar(31[a]):

main(-65,_,a+1)
:
main((*a == '/') + t, _, a + 1 )
:

0<t?

main ( 2, 2 , "%s")
:*a=='/'||

main(0,

main(-61,*a, "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry")

,a+1);}

badcode.c

#include<stdio.h>
#include<string.h>

main()
{
  char*O,l[999]="'`acgo\177~|xp .-\0R^8)NJ6%K4O+A2M(*0ID57$3G1FBL";
  while(O=fgets(l+45,954,stdin)){
    *l=O[strlen(O)[O-1]=0,strspn(O,l+11)];
    while(*O)switch((*l&&isalnum(*O))-!*l){
      case-1:{char*I=(O+=strspn(O,l+12)+1)-2,O=34;
      while(*I&3&&(O=(O-16<<1)+*I---'-')<80);
      putchar(O&93?*I&8||!(I=memchr(l,O,44))?'?':I-l+47:32);
      break;
      case 1:;}*l=(*O&31)[l-15+(*O>61)*32];
      while(putchar(45+*l%2),(*l=*l+32>>1)>35);
    case 0:putchar((++O,32));}
    putchar(10);}
}

precompile.c

#include <stdio.h>

#define PII 3.1415
#define EURO 5.95
#define SALUTE "Did You know:\n"
#define MACRO printf("This is called Macro\n");
#define PRINT_THIS_OUT(a,b) printf(a,b) 

void subprogram(void);

int main(void)
{
  printf (SALUTE);
  PRINT_THIS_OUT ("1 EURO is %f marks\n",EURO);
  printf ("and the value of PII is %f\n",PII);
  MACRO
    subprogram();
}

void subprogram(void)
{
  printf("Definitions work also here\n");
  printf("The area of a circle with diameter of 10 cm is %.2f\n",PII*PII*10);
  MACRO
    }

can u explain these code, wat these code do???

i compiled them but i dont understand them, can u help me???

because this is an excercise teacher gave me so i have to do it. thank 4 help.

because this is an excercise teacher gave me so i have to do it. thank 4 help.

I'd hate to be in that class or have that "teacher".

can u explain these code, wat these code do???

You've got your canonical 12 Days of Christmas, a morse code translator, and an example of making code difficult to understand using preprocessor macros.

> because this is an excercise teacher gave me so i have to do it. thank 4 help.
Your teacher is an idiot. They probably no more understand the code than you do, since all they did was grab it from the ioccc site and hand it to you.

You're NOT going to learn how to program from them. Figuring out that code will tell you NOTHING (that's NOTHING!) about how to write a C program.
Real code produced by professionals in the real world looks nothing like that kind of crap.

Feel free to direct them to this forum.

Has this so-called 'teacher' told you at any time to use any of these?
- void main
- fflush(stdin)
- conio.h
- gets(buffer)
If the answer is "all of them", then be very afraid.
I'd be worried the the answer was even any of them.

Actually, you'd probably be better off failing/dropping the class than soaking up more broken information from them.

teacher doesnt teach me anything... he say we have to reseach is by ourshelf...

i dont need to understand them anymore because i can not understand that but i still completed this excersice...

please, help me answer these question ...

Description what does the bad.c and badcode.c do
Your own findings

Edited 6 Years Ago by tien113: n/a

- visit ioccc
- download the appropriate entries
- read the associated descriptions (most entries have some explanation)
- copy/paste that description to your teacher

Like I said, finding someone else to teach you is probably your best move at this point. So even if they kick you out for cheating, they're doing you a favour.

Teacher of "programming circus tricks", that is all.
Something to make the crowd go "oohh" and "ahhh", but serving no actual purpose than to entertain for a while.

This article has been dead for over six months. Start a new discussion instead.