Skip to content

Commit 5bfe79b

Browse files
committed
c使用异或方式交换两个值
1 parent c67587f commit 5bfe79b

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

CCodes/SwapValue/SwapValue.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<stdio.h>
2+
3+
void swap(int *a, int *b)
4+
{
5+
printf("%p, %p\n", a, b);
6+
*a = *a ^ *b;
7+
*b = *a ^ *b;
8+
*a = *b ^ *a;
9+
}
10+
11+
void main()
12+
{
13+
int a = 3;
14+
int b = 2;
15+
16+
printf("%d, %d\n", a, b);
17+
18+
swap(&a, &b);
19+
20+
printf("%d, %d\n", a, b);
21+
22+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
header("content-type:text/html;charset=utf-8");
3+
4+
/**
5+
代理模式:
6+
*/
7+
class Proxy
8+
{
9+
10+
}
11+
12+
class Test
13+
{
14+
public function run()
15+
{
16+
17+
}
18+
}
19+
20+
$test = new Test();
21+
$test->run();

0 commit comments

Comments
 (0)