Possible Duplicate:
Sum of positive integers. (Spoj - SIZECON)

Here is the question:- Given the set of integers, find the sum of all positive integers in it. Input t – number of test cases [t < 1000] On each of next t lines given a integer N [-1000 <= N <= 1000]

Output One integer equals to sum of all positive integers.

Source code of program should be less than 65 characters. white space and tabs are not counted.

my code is:--

return 0;  

source code is of 90 characters. I have reduced my code upto this from 122 characters , now I am unable to reduce it further, what should I do. I have also used atoi(gets(&t)) instead of scanf(x,&t); but time limit exceeds. return 0 is necessary in program otherwise it is giving NZEC runtime error. I don't know what to do more to reduce my sorce code. Help me Sir.

  • \$\begingroup\$ Your source doesn't even look correct - or, at least, you're relying on unspecified behaviour of scanf. \$\endgroup\$ Apr 10 '11 at 15:27
  • \$\begingroup\$ sry my code is:---codex="%d";main(b,a,t) { for(scanf(x,&t);t;t--) {scanf(x,&a);if(a>0)b+=a;} printf(x,b-1); return 0; } it is showing 90 characters in spoj.pl judging \$\endgroup\$
    – avinashse
    Apr 10 '11 at 16:48
  • 1
    \$\begingroup\$ @aavinshse: You know, you can edit a question afterwards. Just hit the gray button marked »edit«. \$\endgroup\$
    – FUZxxl
    Apr 10 '11 at 16:52
  • \$\begingroup\$ Do you mean this to be in C only or for any language? \$\endgroup\$ Apr 10 '11 at 17:19
  • \$\begingroup\$ yes only for c language... \$\endgroup\$
    – avinashse
    Apr 10 '11 at 17:58

Browse other questions tagged or ask your own question.