作者在 2016-08-18 09:43:13 发布以下内容
#include <stdio.h>
#define N 80
void fun(int *w,int p,int n)
{
int i=0,c;
while(i<=p)
{
i=0;
c=w[i];
w[i]=w[i+1];
w[n-1-i]=c;
i+=1;
}
}
int main()
{
int a[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int i,p,n=15;
printf("The original data:\n");
for(i=0;i<n;i++)
{
printf("%3d",a[i]);
}
printf("\n\nEnter p:");
scanf("%d",&p);
fun(a,p,n);
printf("\nThe data after moving:\n");
for(i=0;i<n;i++)
{
printf("%3d",a[i]);
printf("\n\n");
}
printf("Hello world!\n");
return 0;
}
#define N 80
void fun(int *w,int p,int n)
{
int i=0,c;
while(i<=p)
{
i=0;
c=w[i];
w[i]=w[i+1];
w[n-1-i]=c;
i+=1;
}
}
int main()
{
int a[N]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int i,p,n=15;
printf("The original data:\n");
for(i=0;i<n;i++)
{
printf("%3d",a[i]);
}
printf("\n\nEnter p:");
scanf("%d",&p);
fun(a,p,n);
printf("\nThe data after moving:\n");
for(i=0;i<n;i++)
{
printf("%3d",a[i]);
printf("\n\n");
}
printf("Hello world!\n");
return 0;
}