当前位置:网站首页>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;
}
边栏推荐
- C language series - Section 3 - functions
- Small program animation realizes the running lantern and animation object
- Kingbasees plug-in KDB of Jincang database_ database_ link
- A outsourcing boy's mid-2022 summary
- Reptile exercise 03
- 金仓数据库KingbaseES 插件kdb_date_function
- Database management tool, querious direct download
- What's wrong with SD card data damage? How to recover SD card data damage
- Wine travel Jianghu War: Ctrip is strong, meituan is strong, and Tiktok is fighting
- Feature_selection
猜你喜欢
Jincang KFS data bidirectional synchronization scenario deployment
Prefix and (continuously updated)
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
Web - Information Collection
vulnhub HA: Natraj
Busycal latest Chinese version
Design and implementation of JSP logistics center storage information management system
[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
JS realizes the animation effect of text and pictures in the visual area
After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me
随机推荐
What functions need to be set after the mall system is built
金仓数据库KingbaseES 插件kdb_date_function
GFS distributed file system (it's nice to meet it alone)
使用BENCHMARKSQL工具对KingbaseES预热数据时执行:select sys_prewarm(‘NDX_OORDER_2 ‘)报错
2022 P cylinder filling test content and P cylinder filling simulation test questions
IPhone x forgot the boot password
Five elements of user experience
Asp access teaching management system design finished product
Solve BP Chinese garbled code
After reviewing MySQL for a month, I was stunned when the interviewer of Alibaba asked me
FFMpeg filter
4 years of experience to interview test development, 10 minutes to end, ask too
Priv app permission exception
Xrandr modify resolution and refresh rate
Web - Information Collection
Arthas watch grabs a field / attribute of the input parameter
Redraw and reflow
2022-02-12 (338. Bit count)
[set theory] set operation (Union | intersection | disjoint | relative complement | symmetric difference | absolute complement | generalized union | generalized intersection | set operation priority)
[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius