当前位置:网站首页>数组元素逆置
数组元素逆置
2022-07-30 15:14:00 【51CTO】
using namespace std;
int main1() {
int arr[5] = { 2,3,4,5,6 };
cout << "数组逆置前:" << endl;
for (int i = 0; i < 5; i++) {
cout << arr[i] << endl;
}
int start = 0;//记录起始下标的位置
int end = sizeof(arr) / sizeof(arr[0])-1;//记录结束下标的位置
//实现元素互换
while (start < end) {
int temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
//下标更新
start++;
end--;
}
//打印逆置后的数组
cout << "数组元素逆置后" << endl;
for (int i = 0; i < 5; i++) {
cout<< arr[i] << endl;
}
system("pause");
return 0;
}
边栏推荐
- The Prospects of the Metaverse and the Four Tracks
- tiup clean
- L2-007 家庭房产(vector、set、map的使用)
- Sleuth+Zipkin(可视化) 服务链路追踪
- [Cloud native] Alibaba Cloud ARMS business real-time monitoring
- GeoServer + openlayers
- 软件包 - 笔记
- (Crypto essential dry goods) Detailed analysis of the current NFT trading markets
- websocket flv 客户端解封包
- tiup completion
猜你喜欢

STM32F407定时器输入捕获
![[Cloud native] Alibaba Cloud ARMS business real-time monitoring](/img/e7/55f560196521d22f830b2caf110e34.png)
[Cloud native] Alibaba Cloud ARMS business real-time monitoring

三维重建方法汇总

Alluxio for Presto fu can across the cloud self-service ability

本地事务与分布式事务

(科普文)什么是碎片化NFT(Fractional NFT)
![[Cloud native] Grayscale release, blue-green release, rolling release, grayscale release explanation](/img/90/f7d85ac655d9206fefbd28e0fc81ba.png)
[Cloud native] Grayscale release, blue-green release, rolling release, grayscale release explanation

Example of video switching playback (video switching example) code

Mysql数据库查询好慢,除了索引,还能因为什么?

GeoServer + openlayers
随机推荐
【喂到嘴边了的模块】准备徒手撸GUI?用Arm-2D三分钟就够了
Alluxio为Presto赋能跨云的自助服务能力
深度学习遇到报错Bug解决方法(不定时更新)
Delayed message queue
存储器映射、位带操作
华为云重磅发布开源软件治理服务——软件成分分析
Sleuth+Zipkin(可视化) 服务链路追踪
vite 多页面应用刷新页面时,不会在当前路由中,会返回到根路由
本地事务与分布式事务
调试 - 笔记
Memory-mapped, bit-band operations
Store Limit 使用文档
Overview of TiUP commands
微服务该如何拆分?
转换OTU表和序列文件为PICRUST2需要的格式
EST综述:eDNA的多种状态以及在水环境中持久性的认知
HTTP缓存小结
微服务架构下的核心话题 (二):微服务架构的设计原则和核心话题
被捧上天的Scrum敏捷管理为何不受大厂欢迎了?
TiDB 工具下载