Skip to content

Instantly share code, notes, and snippets.

@sixthgear
Created August 4, 2011 07:33
Show Gist options
  • Select an option

  • Save sixthgear/1124660 to your computer and use it in GitHub Desktop.

Select an option

Save sixthgear/1124660 to your computer and use it in GitHub Desktop.
/* sixthgear's horrible inplace reverse */
#include <stdio.h>
int
main()
{
int i;
int l = 9;
int a[] = {1,2,3,4,5,6,7,8,9};
/* the dirty deed */
for (i=-1; ++i<l+l/2?i%l==l-i%l-1?i++:1:0; a[i%l]^=a[l-i%l-1]);
/* print this mess */
for (i=0; i<l; printf("%d ", a[i++]));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment