Some codes on printing I Love U in C
----------------------------Code 1 ----------------------------------------------------------
#include <stdio.h>
main(_)
{
//for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1););
}
------------------------------------------EOF------------------------------------------------
----------------------------Code 2 ----------------------------------------------------------
#include <stdio.h>
main(_)
{
for(_=!!_?_^_:_; putchar(_++["J!Mpwf!Zpv\1"]-1); );
}
------------------------------------------EOF------------------------------------------------
----------------------------Code 3 ----------------------------------------------------------
#include <stdio.h>
main(_)
{
for(_^=_; putchar(_++["J!Mpwf!Zpv\1"]-1); );
}
------------------------------------------EOF------------------------------------------------
----------------------------Code 4 ----------------------------------------------------------
#include <stdio.h>
main(_)
{
//for(--_;putchar(_++["J!Mpwf!Zpv\1"]-1););
//for(_=!!_?_^_:_; putchar(_++["J!Mpwf!Zpv\1"]-1); );
for(_^=_; putchar(_++["J!Mpwf!Zpv\1"]-1); );
}
------------------------------------------EOF------------------------------------------------
----------------------------Code 5 ----------------------------------------------------------
#include <stdio.h>
// x will be 1 (the name of this app would be in argv[0]) if we
// don't invoke the app with some args.
//
main(x)
{
    char c;
    // zero then!
    //
    --x;
    while(c = "J!Mpwf!Zpv\1"[x])
    {
        // No need for the -1 if we add 1 to the literal's characters...
        //
        // "I Love You\1"
        //
        c = c - 1;
        x++;
        putchar(c);
    }
}
------------------------------------------EOF------------------------------------------------
----------------------------Code 6 ----------------------------------------------------------
#include <stdio.h>
int main(void)
{
   char rubbish[] = "J!Mpwf!Zpv\1"; /* will 'print' trailing '\0' */
   char *rp = rubbish;
   while (*rp)
   {
      putchar ((*rp)-1);
      rp++;
   }
   putchar('\n'); /* not in original code */
}
------------------------------------------EOF------------------------------------------------
----------------------------Code 7 ----------------------------------------------------------
#include <stdio.h>
int main(void)
{
   char rubbish[] = "I Love You\0"; /* '\0' is redundant here */
   char *rp = rubbish;
   while (*rp)
   {
      putchar(*rp);
      rp++;
   }
   putchar('\n'); /* not in original code */
}
------------------------------------------EOF------------------------------------------------
Pradyut 
http://pradyut.tk
http://spaces.msn.com/members/oop-edge/
http://groups-beta.google.com/group/oop_programming
 
 
No comments:
Post a Comment