This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15383|Reply: 1

[C] Store the array in reverse order, and the parameter in the function inv is a pointer variable

[Copy link]
Posted on 12/11/2015 10:20:06 AM | | |
//将数组逆序存放,函数inv中的Shape referencebePointer variable

#include "stdafx.h"
#include "stdio.h"
int main()
{void inv(int *x,int n);
int i,a[10]={3,7,9,11,0,6,7,5,4,2};
printf("the original array:\n");
for(i=0; i<10; i++)
printf("%d",a);
printf("\n");
inv(a,10);
printf("the array has been inverted:\n");
for(i=0; i<10; i++)
printf("%d",a);
printf("\n");
return 0;
}
void inv(int *x,int n) // pointer point of the pointer parameter x pointer variable
{int *p,temp,*i,*j,m=(n-1)/2;
i=x; j=x+n-1; p=x+m;
for(; i<=p; i++,j--)
{temp=*i; *i=*j; *j=temp; } //*i and *J swap
return;
}






Previous:RSA generates public and private keys, as well as encryption and decryption
Next:The parameters of array functions are summarized, and the parameters are different between the form and the real parameters
Posted on 12/11/2015 10:52:39 AM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com