【PTA】字符串正反序连接
2024-10-17 08:57:05
将s所指字符串的正序和反序进行连接,形成一个新串放在t所指的数组中。
函数接口定义:
void fun (char *s, char *t);
其中s
和t
都是用户传入的参数。函数将s
所指字符串的正序和反序进行连接,形成一个新串放在t
所指的数组中。
裁判测试程序样例:
#include <stdio.h>
void fun (char *s, char *t);
int main()
{ char s[100], t[100];
scanf("%s", s);
fun(s, t);
printf("The result is: %s\n", t);
return 0;
}
/* 请在这里填写答案 */
输入样例:
abcd
输出样例:
The result is: abcddcba
void fun (char *s, char *t)
{
int len = 0;
while(*s != '\0')
{
*t = *s;
s++;
t++;
len++;
}
s--;
while(len--)
{
*t = *s;
s--;
t++;
}
*t = '\0';
}
最新文章
- JQuery中隐藏/显示事件函数
- angularjs自动化测试系列之jasmine
- UVa1401 Remember the Word(DP+Trie树)
- 关于C语言链表的学习
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.2.4
- C# Byte[]数组读取和写入文件
- Alamofire网络库基础教程
- LeetCode219:Contains Duplicate II
- sql server 去除字符中空格的方法
- 201521123074 《Java程序设计》第10周学习总结
- 读书笔记二 How Does the Internet work?
- 解决关于ios访问相机闪退问题
- docker 系列 - Dock高阶知识点文章汇集
- WebService简单教程
- python 3 操作mysql数据库的方法
- HBase定期备份
- High Voltage Boost Supply
- Java 引用类型变量的声明和使用
- 【BZOJ2818】Gcd [莫比乌斯反演]
热门文章
- [HarekazeCTF2019]baby_rop
- IDT系统中断描述表以及绕过Xurtr检测的HOOK姿势
- CF46B T-shirts from Sponsor 题解
- CF1491A K-th Largest Value 题解
- Linux 输入指令显示 command not found(未找到命令)解决办法
- 【LeetCode】1414. 和为 K 的最少斐波那契数字数目 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
- 【LeetCode】518. Coin Change 2 解题报告(Python)
- 分析一个简单的goroutine资源池
- 第三十三个知识点:Bellcore攻击是如何攻击使用CRT的RSA的?
- Proximal Algorithms 4 Algorithms