#include <stdio.h>
#define MAXLINE	1000	/* maximum input line size */

int getline_no_nl(char line[], int maxline);
void reverse(char s[]);

int main()
     /* effect: print reverse of each input line */
{
  int len;			/* current line length */
  int max;			/* maximum length seen so far */
  char line[MAXLINE];		/* current input line */

  max = 0;
  while ((len = getline_no_nl(line, MAXLINE)) > 0) {
    reverse(line);
    printf("%s\n", line);
  }
  return 0;
}


int getline_no_nl(char s[], int lim)
   /* requires: lim > 1 */
   /* effect: read a line into s, return length */
{
  int c, i;
 
  for (i=0; i<lim-1 && (c=getchar())!=EOF && c!='\n'; ++i)
    s[i] = c;
  s[i] = '\0';
  return i;
}

#include <string.h>

void reverse(char s[])
   /* effect: reverse s in place */
{
  int head, tail;

  for (head = 0, tail = strlen(s)-1; head < strlen(s)/2; ++head, --tail) {
    char temp = s[head];
    s[head] = s[tail];
    s[tail] = temp;
  }
}
