替换符号

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=208 自己看题吧,把'替换为’

#include <stdio.h>

#include <string.h>

#define N = 1000;

int main(){

 int i,j,cnt=0;  

char src[N],dst[N];  

while(gets(src)){

for(i=j=0;i<strlen(src);i++){    

if(src[i]!='"'){  

   dst[j++]=src[i];    }  

else {  

   cnt=(cnt+1)%2;  

   if(cnt){

     dst[j++]='`'; 

   dst[j++]='`';     }   

  else{      dst[j++]='\'';    

  dst[j++]='\'';         }  

  }   }   

dst[j]='\0';

  printf("%s\n",dst);  }

 return 0; }

posted @ 2013-02-28 18:38  L kill  阅读(198)  评论(0编辑  收藏  举报