Hello.
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.Code:main(a){while(scanf("%d",&a)^-1)printf("%d\n",a*a+a>>1);}
Hello.
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.Code:main(a){while(scanf("%d",&a)^-1)printf("%d\n",a*a+a>>1);}
Last edited by czarny020; 02-12-2011 at 02:36 PM.
Ummm... what on earth are you talking abourt?
I searching a shorter code in C
what??? explain yourself better, and maybe better code example.
And there 's no such thing as
Code:main(a)
"All that we see or seem
Is but a dream within a dream." - Poe
Win!Code:int main(){}
You never said the program had to do anything.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
And there 's no such thing asCode:void foo(a,b,c) /* defaults to int a,b,c; */ { }
The program counts a sum of arithmetic progression starting from 1 to the input number and should stop on invalid input. There is a mistake in czarny020's code: when you enter text, it loops infinitely. My variant fixes the bug and has 54 symbols.
Code:main(a){while(scanf("%d",&a))printf("%d\n",a*a+a>>1);}
Last edited by modwind; 02-13-2011 at 03:37 AM.
I will admit, I see little value in using deprecated and (worse) implementation-defined features to minimise the number of characters in a source file.
iMalc's example aside, the code snippets shown as "solutions" in this thread - at best - will trigger warnings from modern compilers and are also not guaranteed to produce the intended result.
Why bother with short source code? Your compiler will just give you a hard time (spamming warnings) and then (hopefully) compile it to the same machine code anyway. What you should really be looking at is the effectiveness of your algorithm.
Please remember: Shorter source code DOES NOT mean the resulting program will be smaller or faster!
LT
Why so serious? It was just a game to make shorter code. Everyone understands it is not an example for real life. Like assembler demos 256 bytes or 64k long.