当前位置:网站首页>C字符串数组反转
C字符串数组反转
2022-08-01 00:30:00 【ma_de_hao_mei_le】
友链
#include <stdio.h>
#include <string.h>
void reverse(char* s) {
int len = strlen(s);
for (int i = 0; i < len / 2; i++) {
int diff = *(s + i) - *(s + (len - i - 1));
*(s + i) = *(s + i) - diff;
*(s + (len - i - 1)) = *(s + (len - i - 1)) + diff;
}
}
int main()
{
char s[123] = "1234567890";
reverse(s);
printf("%s\n", s);
return 0;
}
边栏推荐
- Rainbow share | how to use moving targets defense technology to guard against the unknown
- An open source and easy-to-use flowchart drawing tool drawio
- Classes and Objects: Medium
- vim的基本使用概念
- /usr/local/bin和/usr/bin的区别
- 字符编码和浮点型计算精度丢失问题
- MYSQL二阶段提交
- Basic use of vim - bottom line mode
- Web API Introduction and Types
- ECCV2022 Workshop | 复杂环境中的多目标跟踪和分割
猜你喜欢
随机推荐
WeChat applet page syntax
[AMEX] LGBM Optuna American Express Credit Card Fraud Contest kaggle
Interview Question: Implementing Deadlocks
To help the construction of digital government, the three parties of China Science and Technology build a domain name security system
lua入门案例实战123DIY
Nmap 操作手册 - 完整版
LeetCode--打家劫舍问题
An open source and easy-to-use flowchart drawing tool drawio
/usr/local/bin和/usr/bin的区别
Application of integrated stepper motor in UAV automatic airport
Carefully summarize thirteen suggestions to help you create more suitable MySQL indexes
一体化步进电机在无人机自动机场的应用
Likou Binary Tree
[微服务]分布式事务解决方案-Seata
两院院士直言:不要迷信院士
MYSQL索引解析
Item 36: Specify std::launch::async if asynchronicity is essential.
【读书笔记->数据分析】02 数据分析准备
How to Design High Availability and High Performance Middleware - Homework
Redis五种数据类型简介