摘要: 一般我们在写程序时如果遇到两个数需要交换时写作如下: 而如果不允许有第三个变量出现即不允许有temp出现时应该如何做呢?可以写作如下: 而利用两个数的异或或许更加巧妙—— 异或有如下性质: 交换律:x^y=y^x 结合律:x^(y^z)=(x^y)^z 而相同的两个数异或则使得此数为0,故两个变量可 阅读全文
posted @ 2016-09-19 18:39 天下岂有长生不灭者 阅读(1961) 评论(0) 推荐(0) 编辑
摘要: 1 import java.io.*; 2 import java.util.Scanner; 3 import java.util.Random; 4 public class Lottery { 5 public int[] Ran(int x,int z,int y,int Is_repeat){//产生z到y的x个随机数, 6 //Is_r... 阅读全文
posted @ 2016-09-19 02:11 天下岂有长生不灭者 阅读(2336) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 using namespace std; 3 int main(){ 4 int Smallest_numberFree = 0;//记录单身的号码最低的男性 5 int i = Smallest_numberFree, n, k = -1;//n代表有多少对男女 6 7 cout > n; 9 int **... 阅读全文
posted @ 2016-09-19 00:18 天下岂有长生不灭者 阅读(917) 评论(0) 推荐(0) 编辑