当前位置:网站首页>[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
边栏推荐
- {1,2,3,2,5}查重问题
- 攻防世界MISC练习区(gif 掀桌子 ext3 )
- 《统计学》第八版贾俊平第五章概率与概率分布
- Statistics 8th Edition Jia Junping Chapter IX summary of knowledge points of classified data analysis and answers to exercises after class
- 《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
- List and data frame of R language experiment III
- [issue 18] share a Netease go experience
- Library management system
- Hackmyvm target series (1) -webmaster
- Captcha killer verification code identification plug-in
猜你喜欢
Xray and burp linkage mining
数字电路基础(五)算术运算电路
Matplotlib绘图快速入门
Intel oneapi - opening a new era of heterogeneity
sqqyw(淡然点图标系统)漏洞复现和74cms漏洞复现
“Hello IC World”
Get started with Matplotlib drawing
Statistics 8th Edition Jia Junping Chapter 5 probability and probability distribution
Statistics, 8th Edition, Jia Junping, Chapter VIII, summary of knowledge points of hypothesis test and answers to exercises after class
Statistics 8th Edition Jia Junping Chapter 14 summary of index knowledge points and answers to exercises after class
随机推荐
“人生若只如初见”——RISC-V
Internet Management (Information Collection)
攻防世界MISC练习区(gif 掀桌子 ext3 )
ES全文索引
This article explains in detail how mockmvc is used in practical work
XSS (cross site scripting attack) for security interview
5分钟掌握机器学习鸢尾花逻辑回归分类
《统计学》第八版贾俊平第七章知识点总结及课后习题答案
WEB漏洞-文件操作之文件包含漏洞
《统计学》第八版贾俊平第十三章时间序列分析和预测知识点总结及课后习题答案
New version of postman flows [introductory teaching chapter 01 send request]
浙大版《C语言程序设计实验与习题指导(第3版)》题目集
Record once, modify password logic vulnerability actual combat
Function: find the root of the equation by Newton iterative method
【指针】使用插入排序法将n个数从小到大进行排列
循环队列(C语言)
Pointeurs: maximum, minimum et moyenne
线程的实现方式总结
msf生成payload大全
指针--剔除字符串中的所有数字