home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!boulder!news
- From: jcook@brazil.cs.colorado.edu (Jonathan Cook)
- Subject: Re: A LITTLE BRAINTEASER... (The REAL solution!)
- Message-ID: <1992Aug14.021537.6943@colorado.edu>
- Sender: Jonathan Cook
- Nntp-Posting-Host: brazil.cs.colorado.edu
- Organization: Universtiy of Colorado, Boulder
- Date: Fri, 14 Aug 1992 02:15:37 GMT
- Lines: 31
-
- In keeping within the spirit of the original post, only one local
- variable used - but I did add argc and argv, and only a recursive
- main. You might call this cheating, but run it . . .
-
-
-
- int main(argc, argv)
- int argc; int *argv;
- {
- int c;
- c = getchar();
- if (c == EOF) return(0);
- if (c != '\n')
- {
- main(argc+1,&c);
- }
- else
- {
- main(1,NULL);
- c = ((int) (&c - argv));
- argv -= c * (argc-2);
- while (argv != &c)
- {
- putchar(*argv);
- argv += c;
- }
- putchar('\n');
- }
- return(0);
- }
-
-