当前位置:网站首页>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;
}边栏推荐
- 金仓数据库KingbaseES 插件kdb_exists_expand
- Redraw and reflow
- RSRS index timing and large and small disc rotation
- 有道云笔记
- 智能合约安全审计公司选型分析和审计报告资源下载---国内篇
- JS realizes lazy loading of pictures
- [set theory] inclusion exclusion principle (including examples of exclusion principle)
- Fcpx template: sweet memory electronic photo album photo display animation beautiful memory
- [nlp] - brief introduction to the latest work of spark neural network
- Priv-app permission异常
猜你喜欢
![[fxcg] inflation differences will still lead to the differentiation of monetary policies in various countries](/img/56/386f0fd6553b8b9711e14c54705ae3.jpg)
[fxcg] inflation differences will still lead to the differentiation of monetary policies in various countries

Youdao cloud notes

GFS分布式文件系统(光是遇见已经很美好了)

Which Bluetooth headset is good about 400? Four Bluetooth headsets with strong noise reduction are recommended

I've been in software testing for 8 years and worked as a test leader for 3 years. I can also be a programmer if I'm not a professional

智能合约安全审计公司选型分析和审计报告资源下载---国内篇

BMZCTF simple_ pop

Asp access teaching management system design finished product

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

2022 registration of G2 utility boiler stoker examination and G2 utility boiler stoker reexamination examination
随机推荐
vulnhub HA: Natraj
Redraw and reflow
Five elements of user experience
Function introduction of member points mall system
Use the benchmarksql tool to perform a data prompt on kingbases. The jdbc driver cannot be found
After job hopping at the end of the year, I interviewed more than 30 companies in two weeks and finally landed
[no title] 2022 chlorination process examination content and free chlorination process examination questions
The time has come for the domestic PC system to complete the closed loop and replace the American software and hardware system
Two points -leetcode-540 A single element in an ordered array
[fairseq] 报错:TypeError: _broadcast_coalesced(): incompatible function arguments
Xrandr modifier la résolution et le taux de rafraîchissement
Factor stock selection scoring model
Youdao cloud notes
[free completion] development of course guidance platform (source code +lunwen)
跨境电商多商户系统怎么选
[set theory] set concept and relationship (set family | set family examples | multiple sets)
使用BENCHMARKSQL工具对KingbaseES预热数据时执行:select sys_prewarm(‘NDX_OORDER_2 ‘)报错
[set theory] inclusion exclusion principle (including examples of exclusion principle)
When using the benchmarksql tool to test the concurrency of kingbasees, there are sub threads that are not closed in time after the main process is killed successfully
Arthas watch grabs a field / attribute of the input parameter