当前位置:网站首页>C primre plus Chapter 10 question 6 inverted array
C primre plus Chapter 10 question 6 inverted array
2022-07-03 04:29:00 【multydoffer】
Write a function , hold int The data in the type array is arranged in reverse order , And test the function in a simple program .
If you don't open an additional array , The code is as follows :( But there may be a better algorithm ?)
#include <stdio.h>
#define SIZE 12
void reverse(int * a, int n);
int main(void)
{
int a[SIZE] = {3, 4431, 43, 23, 35, 35, 1, 34, 234, 35, 3, 1 };
int i = 0;
reverse(a, SIZE);
for(i = 0; i < SIZE; i++)
{
printf("a[%d] ", i);
}
printf("\n");
for(i = 0; i < SIZE; i++)
{
printf("%-6d", a[i]);
}
return 0;
}
void reverse(int * a, int n)
{
int i = 0;
int j = n - 1;
int temp;
for(; i < j; i++, j--)
{
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
return;
}边栏推荐
- [no title] 2022 chlorination process examination content and free chlorination process examination questions
- [set theory] Cartesian product (concept of Cartesian product | examples of Cartesian product | properties of Cartesian product | non commutativity | non associativity | distribution law | ordered pair
- Kubernetes源码分析(一)
- [free completion] development of course guidance platform (source code +lunwen)
- 2022-02-14 (394. String decoding)
- Kubernetes source code analysis (I)
- Library management system based on SSM
- Classes in TS
- 有道云笔记
- [set theory] set concept and relationship (true subset | empty set | complete set | power set | number of set elements | power set steps)
猜你喜欢

How to choose cross-border e-commerce multi merchant system

Competitive product analysis and writing

When using the benchmarksql tool to preheat data for kingbasees, execute: select sys_ Prewarm ('ndx_oorder_2 ') error

MC Layer Target

FISCO bcos zero knowledge proof Fiat Shamir instance source code

Redis persistence principle

2022 t elevator repair simulation examination question bank and t elevator repair simulation examination question bank

使用BENCHMARKSQL工具对kingbasees并发测试时kill掉主进程成功后存在子线程未及时关闭

Prefix and (continuously updated)

Feature_selection
随机推荐
What are the Bluetooth headsets with good sound quality in 2022? Inventory of four high-quality Bluetooth headsets
[set theory] binary relationship (special relationship type | empty relationship | identity relationship | global relationship | divisive relationship | size relationship)
FuncS sh file not found when using the benchmarksql tool to test kingbases
2022 Shandong Province safety officer C certificate examination content and Shandong Province safety officer C certificate examination questions and analysis
IPhone x forgot the boot password
The latest activation free version of Omni toolbox
MC Layer Target
How to process the current cell with a custom formula in conditional format- How to address the current cell in conditional format custom formula?
[software testing-6] & Test Management
Which code editor is easy to use? Code editing software recommendation
x Problem B
GFS distributed file system (it's nice to meet it alone)
Basic types of data in TS
Writing skills of multi plate rotation strategy -- strategy writing learning materials
xrandr修改分辨率与刷新率
vulnhub HA: Natraj
Which Bluetooth headset is cost-effective? Four Bluetooth headsets with high cost performance are recommended
redis 持久化原理
[no title] 2022 chlorination process examination content and free chlorination process examination questions
2022 registration of G2 utility boiler stoker examination and G2 utility boiler stoker reexamination examination