aboutsummaryrefslogtreecommitdiff
path: root/Semestr 4/ask/lista8/swap.c
diff options
context:
space:
mode:
Diffstat (limited to 'Semestr 4/ask/lista8/swap.c')
-rw-r--r--Semestr 4/ask/lista8/swap.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Semestr 4/ask/lista8/swap.c b/Semestr 4/ask/lista8/swap.c
new file mode 100644
index 0000000..e1966fd
--- /dev/null
+++ b/Semestr 4/ask/lista8/swap.c
@@ -0,0 +1,18 @@
+extern int buf[];
+
+int *bufp0 = &buf[0];
+static int *bufp1;
+
+static void incr() {
+ static int count = 0;
+ count++;
+}
+
+void swap() {
+ int temp;
+ incr();
+ bufp1 = &buf[1];
+ temp = *bufp0;
+ *bufp0 = *bufp1;
+ *bufp1 = temp;
+}