home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / programm / 2305 < prev    next >
Encoding:
Text File  |  1992-08-13  |  935 b   |  43 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!boulder!news
  3. From: jcook@brazil.cs.colorado.edu (Jonathan Cook)
  4. Subject: Re: A LITTLE BRAINTEASER... (The REAL solution!)
  5. Message-ID: <1992Aug14.021537.6943@colorado.edu>
  6. Sender: Jonathan Cook 
  7. Nntp-Posting-Host: brazil.cs.colorado.edu
  8. Organization: Universtiy of Colorado, Boulder
  9. Date: Fri, 14 Aug 1992 02:15:37 GMT
  10. Lines: 31
  11.  
  12. In keeping within the spirit of the original post, only one local
  13. variable used - but I did add argc and argv, and only a recursive
  14. main. You might call this cheating, but run it . . .
  15.  
  16.  
  17.  
  18. int main(argc, argv)
  19. int argc; int *argv;
  20. {
  21.    int c;
  22.    c = getchar();
  23.    if (c == EOF) return(0);
  24.    if (c != '\n')
  25.    {
  26.        main(argc+1,&c);
  27.    }
  28.    else
  29.    {
  30.        main(1,NULL);
  31.        c = ((int) (&c - argv));
  32.        argv -= c * (argc-2);
  33.        while (argv != &c)
  34.        {
  35.        putchar(*argv);
  36.        argv += c;
  37.        }
  38.        putchar('\n');
  39.    }
  40.    return(0);
  41. }
  42.  
  43.