void swap(int a ,int b)

{

  a^=b;

  b^=a;  //b =b^a^b //b = b^b^a;//b = a;  按位异或满足交换律

  a^=b; //a = a^b^a //a = a^a^b;//a = b;

}

考研编程练习----swap的更多相关文章

  1. 杭电1013-Digitai Root(这是一道考研编程题-天大2015)

    Digital Roots Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  2. 考研编程练习----m叉树先序和后序所包含的情况

    题目描述: We are all familiar with pre-order, in-order and post-order traversals of binary trees. A comm ...

  3. 考研编程练习----最大公约数与最小公倍数(c语言)

    int gcd(int a, int b){return (a = a % b) ? gcd (b,a): b;} int lcm(int a, int b){return a * b / gcd(a ...

  4. 考研编程练习----Prim算法的c语言实现

    本文引用自泽爷工作室http://www.zeyes.org/study/clang/189.html 算法思想: 1.在把生成树看成一个集合(开始集合为空,到各个结点的距离当然未知) 2.结点与集合 ...

  5. 考研编程练习---StringMatching(后缀表达式)

    题目描述: Finding all occurrences of a pattern in a text is a problem that arises frequently in text-edi ...

  6. 考研编程练习----Kruskal

    #include <stdio.h> #include <stdlib.h>   #define MAX 100   /* 定义边(x,y),权为w */ typedef st ...

  7. 简论数据库乐观悲观锁与并发编程中的CAS

    为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/ShiJiaqi. http://www.cnblogs.com/shijiaqi1066/p/5783205. ...

  8. C++基础知识:泛型编程

    1.泛型编程的概念 ---不考虑具体数据类型的编程模式Swap 泛型写法中的 T 不是一个具体的数据类型,而是泛指任意的数据类型. 2.函数模板 - 函数模板其实是一个具有相同行为的函数家族,可用不同 ...

  9. 【Java并发编程】9、非阻塞同步算法与CAS(Compare and Swap)无锁算法

    转自:http://www.cnblogs.com/Mainz/p/3546347.html?utm_source=tuicool&utm_medium=referral 锁(lock)的代价 ...

随机推荐

  1. 利用cobbler无人值守批量安装centos

    准备: 至少两台机器,分别用作cobbler的服务端和安装测试端 准备一个iso的安装文件,最好是4G多的那个dvd包,以前用网易源上那个centos 6.4 x86_64 通过xen安装时就报错:N ...

  2. windows下注册和取消pg服务的命令

    pg_ctl register [-N servicename] [-U username] [-P password] [-D datadir] [-w][-t seconds] [-o optio ...

  3. Python常用库之二:Pandas

    Pandas是用于数据操纵和分析,建立在Numpy之上的.Pandas为Python带来了两种新的数据结构:Pandas Series和Pandas DataFrame,借助这两种数据结构,我们能够轻 ...

  4. pwnhub_WTP攻击思路--self-xss高级利用

    1.self-xss+302跳转构造csrf的利用: 1.login.php 存在跳转2.http://54.223.108.205:23333/login.php?redirecturl=//vps ...

  5. Odoo字段类型

    转载请注明原文地址:https://www.cnblogs.com/cnodoo/p/9278620.html    一:基本字段类型 Binary:二进制类型,用于保存图片.视频.文件.附件等,在视 ...

  6. Kali-linux使用Metasploitable操作系统

    Metasploitable是一款基于Ubuntu Linux的操作系统.该系统是一个虚拟机文件,从http://sourceforge.net/projects/metasploitable/fil ...

  7. Java50道经典习题-程序34 三个数排序

    题目:输入3个数a,b,c,按大小顺序输出. import java.util.Scanner; public class Prog34 { public static void main(Strin ...

  8. windows环境安装docker,并下载lamp镜像

    1.PC系统:windows10专业版 2.开启Hyper-V 此电脑->右击->属性->控制面板主页->(查看方式为小图标)程序和功能->右上方启动或关闭windows ...

  9. python -- MySQLdb连接mysql数据库

    1. python安装mysql $ pip install mysql-python 2. 数据库连接程序: import MySQLdb # 打开数据库连接db = MySQLdb.connect ...

  10. JDK代码中的优化 之 “avoid getfield opcode”

    在查看String类源码时,常看到注释 /* avoid getfield opcode */ 如 trim()方法 public String trim() { int len = value.le ...