09 2012 档案

摘要:bool findString(char* str, char* t){ if('\0' == *t) return 1; if('*' == *t){while('\0' != *str){if(findString(str++, t + 1))return 1;}}if('\0' == *str)return 0;if('?' == *t || *str == *t){return findString(str + 1, t + 1);}return 0;} 阅读全文
posted @ 2012-09-28 23:05 翛尧 阅读(388) 评论(0) 推荐(0)
摘要:#include<iostream>#include<string>usingnamespacestd;stringadd(conststring&a,conststring&b){stringresult;//用于记录计算结果intlen_a=a.length()-1;intlen_b=b.length()-1;intcarry=0;//进位for(;len_a>=0&&len_b>=0;len_a--,len_b--){intt=(a[len_a]-'0')+(b[len_b]-'0')+c 阅读全文
posted @ 2012-09-21 23:17 翛尧 阅读(401) 评论(0) 推荐(0)
摘要:#include <cstdlib>#include <iostream>using namespace std;int Partition(int list[], int low, int high){ int pivotkey = list[low]; while(low < high) { while(low<high && list[high]>= pivotkey) high--; //找到第一个小于key的记录 if(low < high) list[low++] = list[high];//相当于交换了list[i 阅读全文
posted @ 2012-09-07 16:00 翛尧 阅读(114) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <stdlib.h>static char Queen[8][8];static int a[8];static int b[15];static int c[15];static int iQueenNum = 0;//record statevoid qu(int i);int main(int argc, char *argv[]){ //init int line, column; for(line = 0;line < 8;line++) { a[line] = 0; for(colu... 阅读全文
posted @ 2012-09-06 16:06 翛尧 阅读(133) 评论(0) 推荐(0)
摘要:使用异或a = a^b;b = a^b;a = a^b;异或运算法则 1. a ^ b = b ^ a 2. a ^ b ^ c = a ^ (b ^ c) = (a ^ b) ^ c; 3. d = a ^ b ^ c 可以推出 a = d ^ b ^ c. 4. a ^ b ^ a = b. 阅读全文
posted @ 2012-09-05 16:31 翛尧 阅读(231) 评论(0) 推荐(0)
摘要:int max = ((a+b) + abs(a-b)) / 2; 阅读全文
posted @ 2012-09-05 16:26 翛尧 阅读(181) 评论(0) 推荐(0)