reverse 函数

 2012               11                 22

和书中不同的:

时间原因,只大概说几点,,  

void reverse( char s[ ] )

{

  int i, j;

  char temp;

  i = 0;

  while( s[ i ] != '\0') {

       i++;

  }

  i--;

  if( s[ i ] == '\n') {

   i--;

   }

   j = 0;

   while( j < i) {

       temp = s[ j ];

       s[ j ] = s [ i ];

       s[ i ] = temp;

        i--;

        j++;

        }

}

posted @ 2012-11-22 17:04  江上摆渡翁  阅读(514)  评论(0)    收藏  举报