44(将字符串逆序、顺序存入t中)

44 date:2021.3.21
在这里插入图片描述
要点:
可作程序设计题思考

详细代码如下:

#include <stdio.h>
#include <string.h>

void fun (char  *s, char  *t)
{
    
    
/************found************/
    int   i,sl;
    sl = strlen(s);
    for (i=0; i<sl; i++)
/************found************/
       t[i] = s[sl-i-1];
    for (i=0; i<=sl; i++)
	t[sl+i] = s[i];
    t[2*sl] = '\0';
}

void main()
{
    
      char s[100], t[100];
   printf("\nPlease enter string s:"); scanf("%s", s);
   fun(s, t);
   printf("The result is: %s\n", t);
}


猜你喜欢

转载自blog.csdn.net/weixin_44856544/article/details/115041201