当前位置:网站首页>[pointer] the array is stored in reverse order and output
[pointer] the array is stored in reverse order and output
2022-07-06 14:35:00 【|Light|】
requirement
Programming , Input n An integer is stored in a one-dimensional array , Re store in reverse order and then output .( Use a pointer to achieve )
Code
#include<stdio.h>
/* * This function is used to input a one-dimensional integer array , The input data is stored in the formal parameter a Array * Input data in 0 As an end sign ,0 It is not stored in the array nor included in the total number of input data * The return value is the number of input data */
int input(int a[])
{
int n=0;
int b = 0;
do
{
scanf("%d",&b);
if(b == 0)
break;
else
{
a[n] = b;
n++;
}
}
while(b != 0);
return n;
}
/* * This function is used to calculate the formal parameter array a Storage in reverse order * n by a The number of integers in the array */
void fun(int a[],int n)
{
int b[n],c = 0;
for(int i = n-1;i>=0;i--)
{
b[c] = a[i];
c++;
}
for(int i = 0;i<n;i++)
{
a[i] = b[i];
}
}
main function
int main()
{
int a[200],n;
n=input(a);
fun(a,n);
for(int i=0;i<n;i++)
printf("%d ",a[i]);
return 0;
}
test
Test input
1 3 5 7 0
Output
7 5 3 1
边栏推荐
- 函数:字符串反序存放
- Low income from doing we media? 90% of people make mistakes in these three points
- 内网渗透之内网信息收集(三)
- 《统计学》第八版贾俊平第一章课后习题及答案总结
- JDBC看这篇就够了
- Hackmyvm target series (1) -webmaster
- 《统计学》第八版贾俊平第十一章一元线性回归知识点总结及课后习题答案
- Pointeurs: maximum, minimum et moyenne
- How does SQLite count the data that meets another condition under the data that has been classified once
- Binary search tree concept
猜你喜欢

MySQL中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?

JDBC read this article is enough

Statistics 8th Edition Jia Junping Chapter 3 after class exercises and answer summary

Fundamentals of digital circuit (IV) data distributor, data selector and numerical comparator

sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现

Lintcode logo queries the two nearest saplings

5 minutes to master machine learning iris logical regression classification

Interview Essentials: what is the mysterious framework asking?

Only 40% of the articles are original? Here comes the modification method

内网渗透之内网信息收集(一)
随机推荐
Intel oneapi - opening a new era of heterogeneity
How does SQLite count the data that meets another condition under the data that has been classified once
Network technology related topics
Function: find 1-1/2+1/3-1/4+1/5-1/6+1/7-... +1/n
Xray and Burp linked Mining
[paper reproduction] cyclegan (based on pytorch framework) {unfinished}
指针 --按字符串相反次序输出其中的所有字符
Mathematical modeling idea of 2022 central China Cup
【指针】数组逆序重新存放后并输出
《英特尔 oneAPI—打开异构新纪元》
Data mining - a discussion on sample imbalance in classification problems
Sword finger offer 23 - print binary tree from top to bottom
XSS (cross site scripting attack) for security interview
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
Ucos-iii learning records (11) - task management
High concurrency programming series: 6 steps of JVM performance tuning and detailed explanation of key tuning parameters
我的第一篇博客
Get started with Matplotlib drawing
Record an edu, SQL injection practice
JDBC read this article is enough