shorter code

Hello.
 
main(a){while(scanf("%d",&a)^-1)printf("%d\n",a*a+a>>1);}


My code have 58 symbols. Is somebody who can to find a shorter code? I know that in C can go up to 53 symbols.
int main(){return 0;}

This code is shorter, and it's correct C++, and it compiles.
closed account (zb0S216C)
main(a){while(scanf("%d",&a)^-1)printf("%d\n",a*a+a>>1);}
What's this all about?
It is C, not C++, and it is perfectly valid on compilers that automatically #include <stdio.h> and accept the aberrant argument list.

That said, I don't think presuming EOF is -1 is very kosher either... Also, if this is anyhing other than playing around then you are making a mistake...

Other than all that, I don't see any way to shorten it...
Last edited on
What in the name of holy beelzebub does this code do?
transforms input numbers through the function
       │x2+x│
f(x) = │────│
       └  2 ┘
Topic archived. No new replies allowed.