aboutsummaryrefslogtreecommitdiffstats
path: root/csci5271/hw1/hw1p4.c
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-01-11 10:18:56 -0600
committerMatt Strapp <matt@mattstrapp.net>2022-01-11 10:18:56 -0600
commit6c9b79537f03115c5e2d4883fd407a6ac870bffd (patch)
treea26cecd37bb254795e8a847ca7235d5e7236ff54 /csci5271/hw1/hw1p4.c
parentfinish 3606 (diff)
downloadhomework-6c9b79537f03115c5e2d4883fd407a6ac870bffd.tar
homework-6c9b79537f03115c5e2d4883fd407a6ac870bffd.tar.gz
homework-6c9b79537f03115c5e2d4883fd407a6ac870bffd.tar.bz2
homework-6c9b79537f03115c5e2d4883fd407a6ac870bffd.tar.lz
homework-6c9b79537f03115c5e2d4883fd407a6ac870bffd.tar.xz
homework-6c9b79537f03115c5e2d4883fd407a6ac870bffd.tar.zst
homework-6c9b79537f03115c5e2d4883fd407a6ac870bffd.zip
Resume and rearrange
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'csci5271/hw1/hw1p4.c')
-rw-r--r--csci5271/hw1/hw1p4.c32
1 files changed, 0 insertions, 32 deletions
diff --git a/csci5271/hw1/hw1p4.c b/csci5271/hw1/hw1p4.c
deleted file mode 100644
index 4526e43..0000000
--- a/csci5271/hw1/hw1p4.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdio.h>
-
-/* Reverse the elements from FROM to TO, inclusive */
-void reverse_range(int *a, int from, int to)
-{
- unsigned int *p = &a[from];
- unsigned int *q = &a[to];
- /* Until the pointers move past each other: */
- while (!(p == q + 1 || p == q + 2))
- {
- /* Swap *p with *q, without using a temporary variable */
- *p += *q; /* *p == P + Q */
- *q = *p - *q; /* *q == P + Q - Q = P */
- *p = *p - *q; /* *p == P + Q - P = Q */
- /* Advance pointers towards each other */
- p++;
- q--;
- }
-}
-
-int main()
-{
- int a[10] = {255, 0, -65536, 2147483647, -2147483648,
- -1, 0, 1, 2, 3};
- reverse_range(a, 9, 0);
- for (int i = 0; i < 10; i++)
- {
- printf("%d ", a[i]);
- }
- printf("\n");
- return 0;
-} \ No newline at end of file