/*
 * Written by Matz Kindahl (matkin@docs.uu.se)
 *
 * A simple program that either sums all arguments together (it there
 * are any) or sums all the numbers supplied on the standard input, if
 * there are no arguments.
 */

#include <stdio.h>
#ifdef __STDC__
#include <stdlib.h>
#endif

char buf[80];

void main(ac, av)
     int ac;
     char **av;
{
  long int sum = 0;

  if (ac > 1)
    while (ac > 1)
      sum += atoi(av[--ac]);
  else
    while (fgets(buf, sizeof(buf), stdin))
      sum += atoi(buf);

  printf("%ld\n", sum);
}
  

