码迷,mamicode.com
首页 > 其他好文 > 详细

怎样实现字符串的反转

时间:2014-11-20 21:41:46      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:io   ar   sp   for   div   bs   ef   nbsp   har   

#include <stdio.h>

#define N 20

int main(void)

{

  int tmp,n=0;

  int i,j;

  char str[N];

   printf("请输入一串字符:\n");

   scanf("%d",str);

   while(str[n]!=‘\0‘)

     n++;

  for(i=0,j=n-1,i<j;i++,j--)

{

    tmp=str[i];

    str[i]=str[j];

    str[j]=tmp;

}

    printf("%s\n",str);

    return 0;

}

  

 

 

 

 

 

 
 

怎样实现字符串的反转

标签:io   ar   sp   for   div   bs   ef   nbsp   har   

原文地址:http://www.cnblogs.com/jjl591362424/p/4111387.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!