当前位置:网站首页>Array element inverse
Array element inverse
2022-07-30 15:53:00 【51CTO】
using namespace std;
int main1() {
int arr[5] = { 2,3,4,5,6 };
cout << "before array inversion:" << endl;
for (int i = 0; i < 5; i++) {
cout << arr[i] << endl;
}
int start = 0;//Record the position of the starting subscript
int end = sizeof(arr) / sizeof(arr[0])-1;//The position of the end subscript of the record
//Realize element exchange
while (start < end) {
int temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
//Subscript update
start++;
end--;
}
//Print the reversed array
cout << "Array elements are inverted" << endl;
for (int i = 0; i < 5; i++) {
cout<< arr[i] << endl;
}
system("pause");
return 0;
}
边栏推荐
- php字符串如何去除第一个字符
- yarn的安装及使用教程
- [Cloud native] Grayscale release, blue-green release, rolling release, grayscale release explanation
- Local Transactions vs Distributed Transactions
- TiUP terms and core concepts
- golang modules initialization project
- 数据库 - 创建数据库、表、函数等
- FME实现CAD带属性转SHP数据方法
- 服务器装好系统的电脑怎么分区
- Placement Rules usage documentation
猜你喜欢
【AGC】质量服务1-崩溃服务示例
Shell脚本的概念
【HMS core】【Media】【视频编辑服务】 在线素材无法展示,一直Loading状态或是网络异常
谷歌工程师『代码补全』工具;『Transformers NLP』随书代码;FastAPI开发模板;PyTorch模型加速工具;前沿论文 | ShowMeAI资讯日报
华为「天才少年」计划招募的博士们,迎来首秀!
(Popular Science) What is Fractional NFT (Fractional NFT)
Database - SQL
在树莓派上驱动CSI摄像头
PMP每日一练 | 考试不迷路-7.30(包含敏捷+多选)
RobotStudio实现喷漆、打磨等功能(曲面路径生成与仿真)
随机推荐
在树莓派上驱动CSI摄像头
工具| execsnoop 短时进程追踪工具
【重磅来袭】教你如何在RGBD三维重建中获取高质量模型纹理
代码随想录笔记_哈希_1l两数之和
Store Limit usage documentation
timed task corn
【HMS core】【Media】【视频编辑服务】 在线素材无法展示,一直Loading状态或是网络异常
php如何查询字符串出现位置
[HMS core] [FAQ] Collection of typical problems of push kit, AR Engine, advertising service, scanning service 2
Excel uses Visual Basic Editor to modify macros
Troubleshooting TiUP
Data Analysis Tools - DDL operations & DML operations in HQL
Introduction to TiUP
481-82 (105, 24, 82, 34, 153),
tiup env
使用 TiUP 命令管理组件
TiUP FAQ
五只小猪的案例(五只小猪 比较体重的大小)
[AGC] Quality Service 1 - Example of Crash Service
影像信息提取DEM