View Code of Problem 79

#include <stdio.h>
#include <malloc.h>
int move(int a[10000],int x,int n){
	int i,t;
	for(i = 0;i<x/2;i++){
		t = a[n-i-1];
		a[n-i-1] = a[n-x+i];
		a[n-x+i] = t;
	}
	for(i = 0;i<(n-x)/2;i++){
		t = a[n-x-1-i];
		a[n-x-i-1] = a[i];
		a[i] = t;
	}
	for(i = n-1;i>=0;i--)
		printf("%d ",a[i]);
	return 0;
}
main(){
	int n,*a,x,i;
	scanf("%d",&n);
	a = (int *)malloc(n*sizeof(int));
	for(i =0;i<n;i++)
		scanf("%d",&a[i]);
	scanf("%d",&x);
	move(a,x,n);
	return 0;
}

Double click to view unformatted code.


Back to problem 79